1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_packages.git synced 2024-08-16 10:19:51 +02:00
ansible_role_packages/tasks/packages.yml
2024-04-27 02:43:22 +02:00

60 lines
1.7 KiB
YAML

---
- name: Update apt repo-cache on debian/ubuntu hosts
become: true
ansible.builtin.apt:
update_cache: true
cache_valid_time: 3600
when:
- ansible_pkg_mgr == "apt"
- name: Update dnf repo-cache on RHEL/Fedora hosts
become: true
ansible.builtin.dnf:
update_cache: true
when:
- ansible_os_family == 'RedHat' and ansible_distribution_version | float >= 8
- name: Create Package installation list
block:
- name: Adding Advances Packages to installation list
ansible.builtin.set_fact:
packages__advanced: []
when:
not packages__install_advanced | bool
- name: Adding Python Packages to installation list
ansible.builtin.set_fact:
lpackages__python: []
when:
not packages__install_python | bool
- name: Adding CLI Packages to installation list
ansible.builtin.set_fact:
packages__cli: []
when:
not packages__install_cli | bool
- name: Combine Lists
ansible.builtin.set_fact:
packages__install: "{{ packages__base + packages__advanced + packages__python + packages__cli + packages__install_extra_packages }}"
- name: Show packages__install on verbose run # noqa: H500
ansible.builtin.debug:
msg: "{{ packages__install }}"
verbosity: 1
rescue:
- name: Show packages__install on verbose run # noqa: H500
ansible.builtin.debug:
msg: "{{ packages__install }}"
verbosity: 1
- name: Error Info
ansible.builtin.fail:
msg: "Error creating list of packages for installation."
- name: Install selected Packages
become: true
ansible.builtin.package:
name: "{{ item }}"
state: "{{ packages__package_state }}"
loop: "{{ packages__install | flatten(1) }}"