--- /dev/null
+# Molecule managed
+
+{% if item.registry is defined %}
+FROM {{ item.registry.url }}/{{ item.image }}
+{% else %}
+FROM {{ item.image }}
+{% endif %}
+
+RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
+ elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \
+ elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
+ elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \
+ elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
+ elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi
--- /dev/null
+import os
+import pytest
+from os.path import expanduser
+
+import testinfra.utils.ansible_runner
+
+testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
+ os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
+
+
+@pytest.fixture
+def get_vars(host):
+ defaults_files = "file=../../defaults/main.yml name=role_defaults"
+ ansible_vars = host.ansible(
+ "include_vars",
+ defaults_files)["ansible_facts"]["role_defaults"]
+ return ansible_vars
+
+
+def test_authorized_keys(host, get_vars):
+ public_key_file = get_vars['offline_ssh_key_file_name'] + '.pub'
+ with open(expanduser("~") + '/.ssh/' + public_key_file, 'r') as pkf:
+ public_key_content = pkf.read().strip()
+
+ f = host.file('/root/.ssh/authorized_keys')
+ assert f.exists
+ assert f.user == 'root'
+ assert f.group == 'root'
+ assert oct(f.mode) == '0o600'
+ assert f.content_string == public_key_content