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
2023-07-31 16:45:00 +02:00

58 lines
1.9 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
blocks:
- name: Create Package installation list
ansible.builtin.set_fact:
l3d_pkgs__install: "{{ l3d_pkgs__base }}"
- name: Adding Advances Packages to installation list
ansible.builtin.set_fact:
l3d_pkgs__install: "{{ l3d_pkgs__install | ansible.builtin.combine(l3d_pkgs__advanced) }}"
when:
l3d_pkgs__install_advanced | bool
- name: Adding Python Packages to installation list
ansible.builtin.set_fact:
l3d_pkgs__install: "{{ l3d_pkgs__install | ansible.builtin.combine(l3d_pkgs__python) }}"
when:
l3d_pkgs__install_python | bool
- name: Adding CLI Packages to installation list
ansible.builtin.set_fact:
l3d_pkgs__install: "{{ l3d_pkgs__base | ansible.builtin.combine(l3d_pkgs__cli) }}"
when:
l3d_pkgs__install_cli | bool
- name: Adding extra Packages to installation list
ansible.builtin.set_fact:
l3d_pkgs__install: "{{ l3d_pkgs__base | ansible.builtin.combine(l3d_pkgs__install_extra_packages) }}"
- name: Show l3d_pkgs__install on verbose run
ansible.builtin.debug:
msg: "{{ l3d_pkgs__install }}"
verbosity: 1
rescue:
ansible.builtin.fail:
msg: "Error creating list of packages for installation. Created list: {{ l3d_pkgs__install }}"
- name: Install selected Packages
become: true
ansible.builtin.package:
name: "{{ item }}"
state: "{{ l3d_pkgs__package_state }}"
with_items: "{{ l3d_pkgs__install }}"