feat: remove become from role, fix #6
All checks were successful
test / Linting (push) Successful in 20s
test / Molecule tests (default, debian12) (push) Successful in 47s
test / Molecule tests (default, ubuntu2004) (push) Successful in 56s
test / Molecule tests (default, ubuntu2204) (push) Successful in 1m10s
test / Molecule tests (with_custom_repo, debian11) (push) Successful in 54s
test / Molecule tests (with_custom_repo, debian12) (push) Successful in 54s
test / Molecule tests (with_custom_repo, ubuntu2004) (push) Successful in 58s
test / Molecule tests (with_custom_repo, ubuntu2204) (push) Successful in 58s
test / Molecule tests (default, debian11) (push) Successful in 44s

This commit is contained in:
Bertrand Lanson 2023-12-03 17:56:58 +01:00
parent 5dd14ee70b
commit f158c340d7
10 changed files with 7 additions and 75 deletions

View File

@ -3,5 +3,4 @@
- name: "Update repositories caches" - name: "Update repositories caches"
ansible.builtin.apt: ansible.builtin.apt:
update_cache: true update_cache: true
become: true
listen: "debian-based-cache-update" listen: "debian-based-cache-update"

View File

@ -1,6 +1,7 @@
--- ---
- name: Converge - name: Converge
hosts: all hosts: all
become: true
tasks: tasks:
- name: "Include manage_repositories" - name: "Include manage_repositories"
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/apt/sources.list" - name: "Test: file /etc/apt/sources.list"
block: block:
- name: "Stat file /etc/apt/sources.list" - name: "Stat file /etc/apt/sources.list"

View File

@ -1,6 +1,7 @@
--- ---
- name: Converge - name: Converge
hosts: all hosts: all
become: true
tasks: tasks:
- name: "Include ednxzu.manage_repositories" - name: "Include ednxzu.manage_repositories"
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/apt/sources.list" - name: "Test: file /etc/apt/sources.list"
block: block:
- name: "Stat file /etc/apt/sources.list" - name: "Stat file /etc/apt/sources.list"

View File

@ -1,6 +1,7 @@
--- ---
- name: Converge - name: Converge
hosts: all hosts: all
become: true
tasks: tasks:
- name: "Include manage_repositories" - name: "Include manage_repositories"
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/apt/sources.list" - name: "Test: file /etc/apt/sources.list"
block: block:
- name: "Stat file /etc/apt/sources.list" - name: "Stat file /etc/apt/sources.list"

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/apt/sources.list" - name: "Test: file /etc/apt/sources.list"
block: block:
- name: "Stat file /etc/apt/sources.list" - name: "Stat file /etc/apt/sources.list"

View File

@ -9,7 +9,6 @@
when: item.options is defined when: item.options is defined
and item.options['Signed-By'] is defined and item.options['Signed-By'] is defined
and item.options['Signed-By'] not in [None, ''] and item.options['Signed-By'] not in [None, '']
become: true
- name: "Configure custom repositories" - name: "Configure custom repositories"
vars: vars:
@ -21,6 +20,5 @@
owner: root owner: root
group: root group: root
loop: "{{ manage_repositories_custom_repo }}" loop: "{{ manage_repositories_custom_repo }}"
become: true
notify: notify:
- "debian-based-cache-update" - "debian-based-cache-update"

View File

@ -7,7 +7,6 @@
src: "{{ manage_repositories_sources_list_location }}" src: "{{ manage_repositories_sources_list_location }}"
register: sources_list_current_content register: sources_list_current_content
ignore_errors: true ignore_errors: true
become: true
- name: "Convert sources.list current content to string" - name: "Convert sources.list current content to string"
ansible.builtin.set_fact: ansible.builtin.set_fact:
@ -25,7 +24,6 @@
group: root group: root
mode: '0644' mode: '0644'
when: sources_list_current_content_str == '' when: sources_list_current_content_str == ''
become: true
- name: "Replace content of /etc/apt/sources.list" - name: "Replace content of /etc/apt/sources.list"
ansible.builtin.replace: ansible.builtin.replace:
@ -33,7 +31,6 @@
regexp: "{{ sources_list_current_content_str | regex_escape }}" regexp: "{{ sources_list_current_content_str | regex_escape }}"
replace: "{{ sources_list_new_content }}" replace: "{{ sources_list_new_content }}"
when: sources_list_current_content_str != 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 }} " - name: "Configure main repositories into sources.list.d for {{ ansible_distribution|lower }} "
ansible.builtin.deb822_repository: ansible.builtin.deb822_repository:
@ -43,6 +40,5 @@
suites: "{{ item.suites | join(' ') }}" suites: "{{ item.suites | join(' ') }}"
components: "{{ item.components }}" components: "{{ item.components }}"
loop: "{{ manage_repositories_default_repo }}" loop: "{{ manage_repositories_default_repo }}"
become: true
notify: notify:
- "debian-based-cache-update" - "debian-based-cache-update"