Bertrand Lanson
edf6d4b74e
Some checks failed
test / Linting (push) Failing after 11s
test / Molecule tests (default, debian11) (push) Has been skipped
test / Molecule tests (default, debian12) (push) Has been skipped
test / Molecule tests (default, ubuntu2004) (push) Has been skipped
test / Molecule tests (default, ubuntu2204) (push) Has been skipped
test / Molecule tests (with_ssh_keys, debian11) (push) Has been skipped
test / Molecule tests (with_ssh_keys, debian12) (push) Has been skipped
test / Molecule tests (with_ssh_keys, ubuntu2004) (push) Has been skipped
test / Molecule tests (with_ssh_keys, ubuntu2204) (push) Has been skipped
74 lines
2.5 KiB
YAML
74 lines
2.5 KiB
YAML
---
|
|
- name: Verify
|
|
hosts: all
|
|
gather_facts: true
|
|
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"
|
|
vars:
|
|
etc_hosts_group:
|
|
ubuntu: "adm"
|
|
debian: "root"
|
|
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 == etc_hosts_group[(ansible_distribution|lower)]
|
|
|
|
- name: "Test: ubuntu user and group"
|
|
block:
|
|
- name: "Getent user ansible"
|
|
ansible.builtin.getent:
|
|
database: passwd
|
|
key: ubuntu
|
|
register: ednxzu_management_user
|
|
|
|
- name: "Getent group ubuntu"
|
|
ansible.builtin.getent:
|
|
database: group
|
|
key: ubuntu
|
|
register: ednxzu_management_group
|
|
|
|
- name: "Verify ubuntu user and group"
|
|
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()"
|
|
|
|
- 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
|
|
become: true
|
|
|
|
- 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
|
|
become: true
|
|
|
|
- name: "Verify file /home/ubuntu/.ssh/authorized_keys"
|
|
ansible.builtin.assert:
|
|
that:
|
|
- not stat_home_ubuntu_ssh_authorized_keys.stat.exists
|