From 2ed6f6ce8b8accd4f70cc2e424f388d0f8fe706a Mon Sep 17 00:00:00 2001 From: Bertrand Lanson Date: Sun, 3 Dec 2023 18:26:11 +0100 Subject: [PATCH] feat: remove become from role, fix #1 --- molecule/default/converge.yml | 1 + molecule/default/verify.yml | 16 +-------------- molecule/default_vagrant/converge.yml | 1 + molecule/default_vagrant/verify.yml | 20 +------------------ molecule/with_custom_ascii/converge.yml | 1 + molecule/with_custom_ascii/verify.yml | 16 +-------------- .../with_custom_ascii_vagrant/converge.yml | 1 + molecule/with_custom_ascii_vagrant/verify.yml | 20 +------------------ tasks/cleanup.yml | 2 -- tasks/configure.yml | 2 -- 10 files changed, 8 insertions(+), 72 deletions(-) diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 8c00c25..c1260b8 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -1,6 +1,7 @@ --- - name: Converge hosts: all + become: true tasks: - name: "Include ednxzu.update_motd" ansible.builtin.include_role: diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml index 5c674dc..af21010 100644 --- a/molecule/default/verify.yml +++ b/molecule/default/verify.yml @@ -2,22 +2,8 @@ - name: Verify hosts: all gather_facts: true + become: 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" - 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" block: - name: "Stat file /etc/profile.d/motd.cfg" diff --git a/molecule/default_vagrant/converge.yml b/molecule/default_vagrant/converge.yml index 8c00c25..c1260b8 100644 --- a/molecule/default_vagrant/converge.yml +++ b/molecule/default_vagrant/converge.yml @@ -1,6 +1,7 @@ --- - name: Converge hosts: all + become: true tasks: - name: "Include ednxzu.update_motd" ansible.builtin.include_role: diff --git a/molecule/default_vagrant/verify.yml b/molecule/default_vagrant/verify.yml index ac10650..af21010 100644 --- a/molecule/default_vagrant/verify.yml +++ b/molecule/default_vagrant/verify.yml @@ -2,26 +2,8 @@ - name: Verify hosts: all gather_facts: true + become: 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: file /etc/profile.d/motd.cfg" block: - name: "Stat file /etc/profile.d/motd.cfg" diff --git a/molecule/with_custom_ascii/converge.yml b/molecule/with_custom_ascii/converge.yml index 8c00c25..c1260b8 100644 --- a/molecule/with_custom_ascii/converge.yml +++ b/molecule/with_custom_ascii/converge.yml @@ -1,6 +1,7 @@ --- - name: Converge hosts: all + become: true tasks: - name: "Include ednxzu.update_motd" ansible.builtin.include_role: diff --git a/molecule/with_custom_ascii/verify.yml b/molecule/with_custom_ascii/verify.yml index ea405fc..f179e5c 100644 --- a/molecule/with_custom_ascii/verify.yml +++ b/molecule/with_custom_ascii/verify.yml @@ -2,22 +2,8 @@ - name: Verify hosts: all gather_facts: true + become: 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" - 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" block: - name: "Stat file /etc/profile.d/motd.cfg" diff --git a/molecule/with_custom_ascii_vagrant/converge.yml b/molecule/with_custom_ascii_vagrant/converge.yml index 8c00c25..c1260b8 100644 --- a/molecule/with_custom_ascii_vagrant/converge.yml +++ b/molecule/with_custom_ascii_vagrant/converge.yml @@ -1,6 +1,7 @@ --- - name: Converge hosts: all + become: true tasks: - name: "Include ednxzu.update_motd" ansible.builtin.include_role: diff --git a/molecule/with_custom_ascii_vagrant/verify.yml b/molecule/with_custom_ascii_vagrant/verify.yml index 8494668..f179e5c 100644 --- a/molecule/with_custom_ascii_vagrant/verify.yml +++ b/molecule/with_custom_ascii_vagrant/verify.yml @@ -2,26 +2,8 @@ - name: Verify hosts: all gather_facts: true + become: 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: file /etc/profile.d/motd.cfg" block: - name: "Stat file /etc/profile.d/motd.cfg" diff --git a/tasks/cleanup.yml b/tasks/cleanup.yml index ec7b8a8..3e32039 100644 --- a/tasks/cleanup.yml +++ b/tasks/cleanup.yml @@ -24,10 +24,8 @@ state: absent loop: "{{ collected_files.files + collected_directories.files }}" when: (item.path|basename) != update_motd_filename - become: true - name: "Remove /etc/motd file" ansible.builtin.file: path: "/etc/motd" state: absent - become: true diff --git a/tasks/configure.yml b/tasks/configure.yml index 2e0616c..ddbe222 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -7,7 +7,6 @@ owner: root group: root mode: '0644' - become: true - name: "Copy motd script file" ansible.builtin.copy: @@ -16,4 +15,3 @@ mode: '0744' owner: root group: root - become: true