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

61 lines
1.7 KiB
YAML
Raw Permalink Normal View History

2020-08-28 13:32:16 +02:00
---
2023-07-31 16:45:00 +02:00
- name: Update apt repo-cache on debian/ubuntu hosts
become: true
ansible.builtin.apt:
update_cache: true
2020-11-11 01:23:46 +01:00
cache_valid_time: 3600
when:
- ansible_pkg_mgr == "apt"
2023-07-31 16:45:00 +02:00
- name: Update dnf repo-cache on RHEL/Fedora hosts
become: true
ansible.builtin.dnf:
update_cache: true
when:
2020-11-11 11:11:17 +01:00
- ansible_os_family == 'RedHat' and ansible_distribution_version | float >= 8
2023-07-31 16:45:00 +02:00
- name: Create Package installation list
2023-07-31 18:18:04 +02:00
block:
2023-07-31 16:45:00 +02:00
- name: Adding Advances Packages to installation list
ansible.builtin.set_fact:
2024-04-27 02:43:22 +02:00
packages__advanced: []
2023-07-31 16:45:00 +02:00
when:
2024-04-27 02:43:22 +02:00
not packages__install_advanced | bool
2023-07-31 16:45:00 +02:00
- name: Adding Python Packages to installation list
ansible.builtin.set_fact:
2024-04-27 02:43:22 +02:00
lpackages__python: []
2023-07-31 16:45:00 +02:00
when:
2024-04-27 02:43:22 +02:00
not packages__install_python | bool
2020-08-28 13:32:16 +02:00
2023-07-31 16:45:00 +02:00
- name: Adding CLI Packages to installation list
ansible.builtin.set_fact:
2024-04-27 02:43:22 +02:00
packages__cli: []
2023-07-31 16:45:00 +02:00
when:
2024-04-27 02:43:22 +02:00
not packages__install_cli | bool
2023-07-31 16:45:00 +02:00
2023-07-31 18:18:04 +02:00
- name: Combine Lists
2023-07-31 16:45:00 +02:00
ansible.builtin.set_fact:
2024-04-27 02:43:22 +02:00
packages__install: "{{ packages__base + packages__advanced + packages__python + packages__cli + packages__install_extra_packages }}"
2023-07-31 16:45:00 +02:00
2024-04-27 02:43:22 +02:00
- name: Show packages__install on verbose run # noqa: H500
2023-07-31 16:45:00 +02:00
ansible.builtin.debug:
2024-04-27 02:43:22 +02:00
msg: "{{ packages__install }}"
2023-07-31 16:45:00 +02:00
verbosity: 1
rescue:
2024-04-27 02:43:22 +02:00
- name: Show packages__install on verbose run # noqa: H500
2023-07-31 18:18:04 +02:00
ansible.builtin.debug:
2024-04-27 02:43:22 +02:00
msg: "{{ packages__install }}"
2023-07-31 18:18:04 +02:00
verbosity: 1
- name: Error Info
ansible.builtin.fail:
msg: "Error creating list of packages for installation."
2023-07-31 16:45:00 +02:00
- name: Install selected Packages
2020-08-29 15:00:05 +02:00
become: true
ansible.builtin.package:
2023-07-31 16:45:00 +02:00
name: "{{ item }}"
2024-04-27 02:43:22 +02:00
state: "{{ packages__package_state }}"
loop: "{{ packages__install | flatten(1) }}"