provision_management_user/molecule/default/verify.yml

68 lines
2.3 KiB
YAML
Raw Normal View History

2023-06-10 20:42:37 +00:00
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: "Test: file /etc/hosts"
block:
- name: "Stat file /etc/hosts"
ansible.builtin.stat:
path: "/etc/hosts"
register: stat_etc_hosts
- name: "Verify file /etc/hosts"
ansible.builtin.assert:
that:
- stat_etc_hosts.stat.exists
- stat_etc_hosts.stat.isreg
- stat_etc_hosts.stat.pw_name == 'root'
- stat_etc_hosts.stat.gr_name == 'root'
- name: "Test: ubuntu user and group"
2023-06-10 20:42:37 +00:00
block:
2023-07-13 21:50:24 +00:00
- name: "Getent user ansible"
2023-06-10 20:42:37 +00:00
ansible.builtin.getent:
database: passwd
key: ubuntu
register: ednxzu_management_user
2023-06-10 20:42:37 +00:00
- name: "Getent group ubuntu"
2023-06-10 20:42:37 +00:00
ansible.builtin.getent:
database: group
key: ubuntu
register: ednxzu_management_group
2023-06-10 20:42:37 +00:00
- name: "Verify ubuntu user and group"
2023-06-10 20:42:37 +00:00
ansible.builtin.assert:
that:
- not ednxzu_management_user.failed
- not ednxzu_management_group.failed
- "'ubuntu' in ednxzu_management_user.ansible_facts.getent_passwd.keys()"
- "'/home/ubuntu' in ednxzu_management_user.ansible_facts.getent_passwd['ubuntu']"
- "'/bin/bash' in ednxzu_management_user.ansible_facts.getent_passwd['ubuntu']"
- "'ubuntu' in ednxzu_management_group.ansible_facts.getent_group.keys()"
2023-07-13 21:50:24 +00:00
- name: "Test: ubuntu sudo permissions"
2023-06-10 20:42:37 +00:00
block:
- name: "Stat file /etc/sudoers.d/ubuntu"
2023-06-10 20:42:37 +00:00
ansible.builtin.stat:
path: "/etc/sudoers.d/ubuntu"
register: stat_etc_sudoers_d_ubuntu
2023-06-10 20:42:37 +00:00
- name: "Verify file /etc/sudoers.d/ubuntu"
2023-06-10 20:42:37 +00:00
ansible.builtin.assert:
that:
- not stat_etc_sudoers_d_ubuntu.stat.exists
2023-06-10 20:42:37 +00:00
- name: "Test: ubuntu authorized_keys"
2023-06-10 20:42:37 +00:00
block:
- name: "Stat file /home/ubuntu/.ssh/authorized_keys"
2023-06-10 20:42:37 +00:00
ansible.builtin.stat:
path: "/home/ubuntu/.ssh/authorized_keys"
register: stat_home_ubuntu_ssh_authorized_keys
2023-06-10 20:42:37 +00:00
- name: "Verify file /home/ubuntu/.ssh/authorized_keys"
2023-06-10 20:42:37 +00:00
ansible.builtin.assert:
that:
- not stat_home_ubuntu_ssh_authorized_keys.stat.exists