Refactor variable names in apt.yml for consistency and clarity
This commit is contained in:
+29
-38
@@ -16,7 +16,7 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
register: apt_config_updated
|
register: common_apt_config_updated
|
||||||
when:
|
when:
|
||||||
- apt_manage_sources_list|bool
|
- apt_manage_sources_list|bool
|
||||||
- ansible_facts['distribution'] == 'Debian'
|
- ansible_facts['distribution'] == 'Debian'
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
- name: (apt.yml) check if legacy /etc/apt/sources.list exists (Debian >= 13)
|
- name: (apt.yml) check if legacy /etc/apt/sources.list exists (Debian >= 13)
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
path: /etc/apt/sources.list
|
path: /etc/apt/sources.list
|
||||||
register: apt_sources_list_stat
|
register: common_apt_sources_list_stat
|
||||||
when:
|
when:
|
||||||
- apt_manage_sources_list|bool
|
- apt_manage_sources_list|bool
|
||||||
- ansible_facts['distribution'] == 'Debian'
|
- ansible_facts['distribution'] == 'Debian'
|
||||||
@@ -60,8 +60,8 @@
|
|||||||
- apt_manage_sources_list|bool
|
- apt_manage_sources_list|bool
|
||||||
- ansible_facts['distribution'] == 'Debian'
|
- ansible_facts['distribution'] == 'Debian'
|
||||||
- (ansible_facts['distribution_major_version'] | int) >= 13
|
- (ansible_facts['distribution_major_version'] | int) >= 13
|
||||||
- apt_sources_list_stat.stat.exists | default(false)
|
- common_apt_sources_list_stat.stat.exists | default(false)
|
||||||
register: apt_sources_list_backup
|
register: common_apt_sources_list_backup
|
||||||
tags:
|
tags:
|
||||||
- apt-configuration
|
- apt-configuration
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
register: apt_config_updated_sources_list
|
register: common_apt_config_updated_sources_list
|
||||||
when:
|
when:
|
||||||
- apt_manage_sources_list|bool
|
- apt_manage_sources_list|bool
|
||||||
- ansible_facts['distribution'] == 'Debian'
|
- ansible_facts['distribution'] == 'Debian'
|
||||||
@@ -91,7 +91,7 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
register: apt_config_updated_debian_sources
|
register: common_apt_config_updated_debian_sources
|
||||||
when:
|
when:
|
||||||
- apt_manage_sources_list|bool
|
- apt_manage_sources_list|bool
|
||||||
- ansible_facts['distribution'] == 'Debian'
|
- ansible_facts['distribution'] == 'Debian'
|
||||||
@@ -106,7 +106,7 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
register: apt_config_updated_security_sources
|
register: common_apt_config_updated_security_sources
|
||||||
when:
|
when:
|
||||||
- apt_manage_sources_list|bool
|
- apt_manage_sources_list|bool
|
||||||
- ansible_facts['distribution'] == 'Debian'
|
- ansible_facts['distribution'] == 'Debian'
|
||||||
@@ -121,7 +121,7 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
register: apt_config_updated_backports_sources
|
register: common_apt_config_updated_backports_sources
|
||||||
when:
|
when:
|
||||||
- apt_manage_sources_list|bool
|
- apt_manage_sources_list|bool
|
||||||
- ansible_facts['distribution'] == 'Debian'
|
- ansible_facts['distribution'] == 'Debian'
|
||||||
@@ -136,7 +136,7 @@
|
|||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: /etc/apt/sources.list.d/backports.sources
|
path: /etc/apt/sources.list.d/backports.sources
|
||||||
state: absent
|
state: absent
|
||||||
register: apt_config_removed_backports_sources
|
register: common_apt_config_removed_backports_sources
|
||||||
when:
|
when:
|
||||||
- apt_manage_sources_list|bool
|
- apt_manage_sources_list|bool
|
||||||
- ansible_facts['distribution'] == 'Debian'
|
- ansible_facts['distribution'] == 'Debian'
|
||||||
@@ -149,14 +149,14 @@
|
|||||||
# can force a fresh cache refresh when repository files changed.
|
# can force a fresh cache refresh when repository files changed.
|
||||||
- name: (apt.yml) aggregate deb822 source changes (Debian >= 13)
|
- name: (apt.yml) aggregate deb822 source changes (Debian >= 13)
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
apt_config_updated:
|
common_apt_config_updated:
|
||||||
changed: >-
|
changed: >-
|
||||||
{{
|
{{
|
||||||
(apt_config_updated_sources_list.changed | default(false))
|
(common_apt_config_updated_sources_list.changed | default(false))
|
||||||
or (apt_config_updated_debian_sources.changed | default(false))
|
or (common_apt_config_updated_debian_sources.changed | default(false))
|
||||||
or (apt_config_updated_security_sources.changed | default(false))
|
or (common_apt_config_updated_security_sources.changed | default(false))
|
||||||
or (apt_config_updated_backports_sources.changed | default(false))
|
or (common_apt_config_updated_backports_sources.changed | default(false))
|
||||||
or (apt_config_removed_backports_sources.changed | default(false))
|
or (common_apt_config_removed_backports_sources.changed | default(false))
|
||||||
}}
|
}}
|
||||||
when:
|
when:
|
||||||
- apt_manage_sources_list|bool
|
- apt_manage_sources_list|bool
|
||||||
@@ -168,7 +168,7 @@
|
|||||||
- name: (apt.yml) apt update
|
- name: (apt.yml) apt update
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
update_cache: true
|
update_cache: true
|
||||||
cache_valid_time: "{{ 0 if apt_config_updated is defined and apt_config_updated.changed else apt_update_cache_valid_time }}"
|
cache_valid_time: "{{ 0 if common_apt_config_updated is defined and common_apt_config_updated.changed else apt_update_cache_valid_time }}"
|
||||||
when: apt_update|bool
|
when: apt_update|bool
|
||||||
tags:
|
tags:
|
||||||
- apt-update
|
- apt-update
|
||||||
@@ -181,9 +181,9 @@
|
|||||||
|
|
||||||
- name: (apt.yml) Configure any half-installed packages 'dpkg --configure -a'
|
- name: (apt.yml) Configure any half-installed packages 'dpkg --configure -a'
|
||||||
ansible.builtin.command: dpkg --configure -a
|
ansible.builtin.command: dpkg --configure -a
|
||||||
register: _dpkg_configure
|
register: common_dpkg_configure
|
||||||
changed_when: (_dpkg_configure.stdout | default('')) | length > 0
|
changed_when: (common_dpkg_configure.stdout | default('')) | length > 0
|
||||||
failed_when: _dpkg_configure.rc != 0
|
failed_when: common_dpkg_configure.rc != 0
|
||||||
when: apt_dpkg_configure|bool
|
when: apt_dpkg_configure|bool
|
||||||
tags:
|
tags:
|
||||||
- apt-dpkg-configure
|
- apt-dpkg-configure
|
||||||
@@ -475,7 +475,12 @@
|
|||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name: "{{ apt_extra_pkgs }}"
|
name: "{{ apt_extra_pkgs }}"
|
||||||
state: "{{ apt_install_state }}"
|
state: "{{ apt_install_state }}"
|
||||||
when: apt_install_extra_pkgs|bool
|
when:
|
||||||
|
- >-
|
||||||
|
(apt_install_extra_pkgs is boolean and apt_install_extra_pkgs)
|
||||||
|
or
|
||||||
|
(apt_install_extra_pkgs is not boolean and (apt_install_extra_pkgs | default([]) | length > 0))
|
||||||
|
- apt_extra_pkgs | default([]) | length > 0
|
||||||
tags:
|
tags:
|
||||||
- apt-extra-pkgs
|
- apt-extra-pkgs
|
||||||
|
|
||||||
@@ -499,20 +504,6 @@
|
|||||||
- apt-compiler-pkgs
|
- apt-compiler-pkgs
|
||||||
- apt-webserver-pkgs
|
- apt-webserver-pkgs
|
||||||
|
|
||||||
#- name: (apt.yml) clean
|
|
||||||
# command: apt-get -y clean
|
|
||||||
# args:
|
|
||||||
# warn: false
|
|
||||||
# changed_when: false
|
|
||||||
# when: apt_clean|bool
|
|
||||||
# tags:
|
|
||||||
# - apt-clean
|
|
||||||
# - apt-initial-install
|
|
||||||
# - apt-microcode
|
|
||||||
# - apt-compiler-pkgs
|
|
||||||
# - apt-mysql-server-pkgs
|
|
||||||
# - apt-webserver-pkgs
|
|
||||||
|
|
||||||
- name: (apt.yml) autoclean cache
|
- name: (apt.yml) autoclean cache
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
autoclean: true
|
autoclean: true
|
||||||
@@ -531,7 +522,7 @@
|
|||||||
- name: (apt.yml) Check if file '/usr/local/mysql/etc/my.cnf' exists
|
- name: (apt.yml) Check if file '/usr/local/mysql/etc/my.cnf' exists
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
path: /usr/local/mysql/etc/my.cnf
|
path: /usr/local/mysql/etc/my.cnf
|
||||||
register: usr_local_mysql_etc_my_cnf
|
register: common_usr_local_mysql_etc_my_cnf
|
||||||
when: groups['mysql_server']|string is search(inventory_hostname) or groups['apache2_webserver']|string is search(inventory_hostname) or
|
when: groups['mysql_server']|string is search(inventory_hostname) or groups['apache2_webserver']|string is search(inventory_hostname) or
|
||||||
groups['nextcloud_server']|string is search(inventory_hostname)
|
groups['nextcloud_server']|string is search(inventory_hostname)
|
||||||
tags:
|
tags:
|
||||||
@@ -542,8 +533,8 @@
|
|||||||
# - name: debug
|
# - name: debug
|
||||||
# debug:
|
# debug:
|
||||||
# msg:
|
# msg:
|
||||||
# - usr_local_mysql_etc_my_cnf.stst.exists = {{ usr_local_mysql_etc_my_cnf.stat.exists }}
|
# - common_usr_local_mysql_etc_my_cnf.stst.exists = {{ common_usr_local_mysql_etc_my_cnf.stat.exists }}
|
||||||
# - "Variable usr_local_mysql_etc_my_cnf: {{ usr_local_mysql_etc_my_cnf }}"
|
# - "Variable common_usr_local_mysql_etc_my_cnf: {{ common_usr_local_mysql_etc_my_cnf }}"
|
||||||
# tags:
|
# tags:
|
||||||
# - check_mysql_cnf
|
# - check_mysql_cnf
|
||||||
|
|
||||||
@@ -557,7 +548,7 @@
|
|||||||
when:
|
when:
|
||||||
- (groups['mysql_server']|string is search(inventory_hostname) or groups['apache2_webserver']|string is search(inventory_hostname) or
|
- (groups['mysql_server']|string is search(inventory_hostname) or groups['apache2_webserver']|string is search(inventory_hostname) or
|
||||||
groups['nextcloud_server']|string is search(inventory_hostname))
|
groups['nextcloud_server']|string is search(inventory_hostname))
|
||||||
- usr_local_mysql_etc_my_cnf.stat.exists
|
- common_usr_local_mysql_etc_my_cnf.stat.exists
|
||||||
tags:
|
tags:
|
||||||
- apt-webserver-pkgs
|
- apt-webserver-pkgs
|
||||||
- apt-mysql-server-pkgs
|
- apt-mysql-server-pkgs
|
||||||
|
|||||||
Reference in New Issue
Block a user