feat: remove become from role, fix #1
All checks were successful
test / Linting (push) Successful in 20s
test / Molecule tests (default, debian11) (push) Successful in 56s
test / Molecule tests (default, debian12) (push) Successful in 1m8s
test / Molecule tests (default, ubuntu2004) (push) Successful in 1m0s
test / Molecule tests (with_custom_ascii, debian11) (push) Successful in 56s
test / Molecule tests (default, ubuntu2204) (push) Successful in 1m24s
test / Molecule tests (with_custom_ascii, debian12) (push) Successful in 1m8s
test / Molecule tests (with_custom_ascii, ubuntu2004) (push) Successful in 59s
test / Molecule tests (with_custom_ascii, ubuntu2204) (push) Successful in 1m7s

This commit is contained in:
Bertrand Lanson 2023-12-03 18:26:11 +01:00
parent 675f4650c9
commit 2ed6f6ce8b
10 changed files with 8 additions and 72 deletions

View File

@ -1,6 +1,7 @@
--- ---
- name: Converge - name: Converge
hosts: all hosts: all
become: true
tasks: tasks:
- name: "Include ednxzu.update_motd" - name: "Include ednxzu.update_motd"
ansible.builtin.include_role: ansible.builtin.include_role:

View File

@ -2,22 +2,8 @@
- name: Verify - name: Verify
hosts: all hosts: all
gather_facts: true gather_facts: true
become: true
tasks: 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: file /etc/profile.d/motd.cfg" - name: "Test: file /etc/profile.d/motd.cfg"
block: block:
- name: "Stat file /etc/profile.d/motd.cfg" - name: "Stat file /etc/profile.d/motd.cfg"

View File

@ -1,6 +1,7 @@
--- ---
- name: Converge - name: Converge
hosts: all hosts: all
become: true
tasks: tasks:
- name: "Include ednxzu.update_motd" - name: "Include ednxzu.update_motd"
ansible.builtin.include_role: ansible.builtin.include_role:

View File

@ -2,26 +2,8 @@
- name: Verify - name: Verify
hosts: all hosts: all
gather_facts: true gather_facts: true
become: true
tasks: 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: file /etc/profile.d/motd.cfg" - name: "Test: file /etc/profile.d/motd.cfg"
block: block:
- name: "Stat file /etc/profile.d/motd.cfg" - name: "Stat file /etc/profile.d/motd.cfg"

View File

@ -1,6 +1,7 @@
--- ---
- name: Converge - name: Converge
hosts: all hosts: all
become: true
tasks: tasks:
- name: "Include ednxzu.update_motd" - name: "Include ednxzu.update_motd"
ansible.builtin.include_role: ansible.builtin.include_role:

View File

@ -2,22 +2,8 @@
- name: Verify - name: Verify
hosts: all hosts: all
gather_facts: true gather_facts: true
become: true
tasks: 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: file /etc/profile.d/motd.cfg" - name: "Test: file /etc/profile.d/motd.cfg"
block: block:
- name: "Stat file /etc/profile.d/motd.cfg" - name: "Stat file /etc/profile.d/motd.cfg"

View File

@ -1,6 +1,7 @@
--- ---
- name: Converge - name: Converge
hosts: all hosts: all
become: true
tasks: tasks:
- name: "Include ednxzu.update_motd" - name: "Include ednxzu.update_motd"
ansible.builtin.include_role: ansible.builtin.include_role:

View File

@ -2,26 +2,8 @@
- name: Verify - name: Verify
hosts: all hosts: all
gather_facts: true gather_facts: true
become: true
tasks: 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: file /etc/profile.d/motd.cfg" - name: "Test: file /etc/profile.d/motd.cfg"
block: block:
- name: "Stat file /etc/profile.d/motd.cfg" - name: "Stat file /etc/profile.d/motd.cfg"

View File

@ -24,10 +24,8 @@
state: absent state: absent
loop: "{{ collected_files.files + collected_directories.files }}" loop: "{{ collected_files.files + collected_directories.files }}"
when: (item.path|basename) != update_motd_filename when: (item.path|basename) != update_motd_filename
become: true
- name: "Remove /etc/motd file" - name: "Remove /etc/motd file"
ansible.builtin.file: ansible.builtin.file:
path: "/etc/motd" path: "/etc/motd"
state: absent state: absent
become: true

View File

@ -7,7 +7,6 @@
owner: root owner: root
group: root group: root
mode: '0644' mode: '0644'
become: true
- name: "Copy motd script file" - name: "Copy motd script file"
ansible.builtin.copy: ansible.builtin.copy:
@ -16,4 +15,3 @@
mode: '0744' mode: '0744'
owner: root owner: root
group: root group: root
become: true