provision_management_user/molecule/default_vagrant/verify.yml

54 lines
1.9 KiB
YAML
Raw Permalink Normal View History

---
- name: Verify
hosts: all
gather_facts: true
2023-12-03 17:10:56 +00:00
become: true
tasks:
- name: "Test: ubuntu user and group"
block:
- name: "Getent user ansible"
ansible.builtin.getent:
database: passwd
key: ubuntu
2024-02-05 21:51:23 +00:00
register: ednz_cloud_management_user
- name: "Getent group ubuntu"
ansible.builtin.getent:
database: group
key: ubuntu
2024-02-05 21:51:23 +00:00
register: ednz_cloud_management_group
- name: "Verify ubuntu user and group"
ansible.builtin.assert:
that:
2024-02-05 21:51:23 +00:00
- not ednz_cloud_management_user.failed
- not ednz_cloud_management_group.failed
- "'ubuntu' in ednz_cloud_management_user.ansible_facts.getent_passwd.keys()"
- "'/home/ubuntu' in ednz_cloud_management_user.ansible_facts.getent_passwd['ubuntu']"
- "'/bin/bash' in ednz_cloud_management_user.ansible_facts.getent_passwd['ubuntu']"
- "'ubuntu' in ednz_cloud_management_group.ansible_facts.getent_group.keys()"
- name: "Test: ubuntu sudo permissions"
block:
- name: "Stat file /etc/sudoers.d/ubuntu"
ansible.builtin.stat:
path: "/etc/sudoers.d/ubuntu"
register: stat_etc_sudoers_d_ubuntu
- name: "Verify file /etc/sudoers.d/ubuntu"
ansible.builtin.assert:
that:
- not stat_etc_sudoers_d_ubuntu.stat.exists
- name: "Test: ubuntu authorized_keys"
block:
- name: "Stat file /home/ubuntu/.ssh/authorized_keys"
ansible.builtin.stat:
path: "/home/ubuntu/.ssh/authorized_keys"
register: stat_home_ubuntu_ssh_authorized_keys
- name: "Verify file /home/ubuntu/.ssh/authorized_keys"
ansible.builtin.assert:
that:
- not stat_home_ubuntu_ssh_authorized_keys.stat.exists