Created
July 15, 2022 06:22
-
-
Save lioneltchami/ff6aec8b15b38f4933a538ef44e2f4fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| - name: Add new repositories keys | |
| apt_key: | |
| url='{{item.key}}' | |
| with_items: "{{ linux_add_packages_keys | default([])}}" | |
| when: linux_add_packages_keys is defined and not (linux_add_packages_keys is none or linux_add_packages_keys | trim == '') | |
| register: aptnewkeys | |
| - name: Add new repositories to sources | |
| apt_repository: | |
| repo='{{item.repo}}' | |
| with_items: "{{ linux_add_packages_repositories | default([])}}" | |
| when: linux_add_packages_repositories is defined and not (linux_add_packages_repositories is none or linux_add_packages_repositories | trim == '') | |
| - name: Force update cache if new keys added | |
| set_fact: | |
| linux_add_packages_cache_valid_time: 0 | |
| when: aptnewkeys.changed | |
| - name: Remove packages | |
| apt: | |
| name={{ item.name }} | |
| state=absent | |
| with_items: "{{ linux_remove_packages_names | default([])}}" | |
| when: linux_remove_packages_names is defined and not (linux_remove_packages_names is none or linux_remove_packages_names | trim == '') | |
| - name: Install packages | |
| apt: | |
| name={{ item.name }} | |
| state=present | |
| update_cache=yes | |
| cache_valid_time={{linux_add_packages_cache_valid_time}} | |
| with_items: "{{ linux_add_packages_names | default([])}}" | |
| when: linux_add_packages_names is defined and not (linux_add_packages_names is none or linux_add_packages_names | trim == '') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment