diff --git a/handlers/main.yml b/handlers/main.yml index 1417c64..0366a00 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -3,5 +3,4 @@ - name: "Update repositories caches" ansible.builtin.apt: update_cache: true - become: true listen: "debian-based-cache-update" diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 57adefb..8374463 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -1,6 +1,7 @@ --- - name: Converge hosts: all + become: true tasks: - name: "Include manage_repositories" ansible.builtin.include_role: diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml index 03f484f..1444489 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/apt/sources.list" block: - name: "Stat file /etc/apt/sources.list" diff --git a/molecule/default_vagrant/converge.yml b/molecule/default_vagrant/converge.yml index 8ebfc23..8d9e40b 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.manage_repositories" ansible.builtin.include_role: diff --git a/molecule/default_vagrant/verify.yml b/molecule/default_vagrant/verify.yml index 3f7fe3d..1444489 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/apt/sources.list" block: - name: "Stat file /etc/apt/sources.list" diff --git a/molecule/with_custom_repo/converge.yml b/molecule/with_custom_repo/converge.yml index 57adefb..8374463 100644 --- a/molecule/with_custom_repo/converge.yml +++ b/molecule/with_custom_repo/converge.yml @@ -1,6 +1,7 @@ --- - name: Converge hosts: all + become: true tasks: - name: "Include manage_repositories" ansible.builtin.include_role: diff --git a/molecule/with_custom_repo/verify.yml b/molecule/with_custom_repo/verify.yml index 8418cb9..31a04ba 100644 --- a/molecule/with_custom_repo/verify.yml +++ b/molecule/with_custom_repo/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/apt/sources.list" block: - name: "Stat file /etc/apt/sources.list" diff --git a/molecule/with_custom_repo_vagrant/verify.yml b/molecule/with_custom_repo_vagrant/verify.yml index 279cdce..31a04ba 100644 --- a/molecule/with_custom_repo_vagrant/verify.yml +++ b/molecule/with_custom_repo_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/apt/sources.list" block: - name: "Stat file /etc/apt/sources.list" diff --git a/tasks/custom_repositories.yml b/tasks/custom_repositories.yml index 95a149e..2d4995a 100644 --- a/tasks/custom_repositories.yml +++ b/tasks/custom_repositories.yml @@ -9,7 +9,6 @@ when: item.options is defined and item.options['Signed-By'] is defined and item.options['Signed-By'] not in [None, ''] - become: true - name: "Configure custom repositories" vars: @@ -21,6 +20,5 @@ owner: root group: root loop: "{{ manage_repositories_custom_repo }}" - become: true notify: - "debian-based-cache-update" diff --git a/tasks/main_repositories.yml b/tasks/main_repositories.yml index 2c800d3..af3e60c 100644 --- a/tasks/main_repositories.yml +++ b/tasks/main_repositories.yml @@ -7,7 +7,6 @@ src: "{{ manage_repositories_sources_list_location }}" register: sources_list_current_content ignore_errors: true - become: true - name: "Convert sources.list current content to string" ansible.builtin.set_fact: @@ -25,7 +24,6 @@ group: root mode: '0644' when: sources_list_current_content_str == '' - become: true - name: "Replace content of /etc/apt/sources.list" ansible.builtin.replace: @@ -33,7 +31,6 @@ regexp: "{{ sources_list_current_content_str | regex_escape }}" replace: "{{ sources_list_new_content }}" when: sources_list_current_content_str != sources_list_new_content - become: true - name: "Configure main repositories into sources.list.d for {{ ansible_distribution|lower }} " ansible.builtin.deb822_repository: @@ -43,6 +40,5 @@ suites: "{{ item.suites | join(' ') }}" components: "{{ item.components }}" loop: "{{ manage_repositories_default_repo }}" - become: true notify: - "debian-based-cache-update"