Initial Commit
This commit is contained in:
53
ansible/tasks/base.yml
Normal file
53
ansible/tasks/base.yml
Normal file
@ -0,0 +1,53 @@
|
||||
---
|
||||
- name: Ensure debian-archive-keyring is installed
|
||||
apt:
|
||||
name: debian-archive-keyring
|
||||
state: present
|
||||
update_cache: yes
|
||||
become: yes
|
||||
|
||||
- name: Update APT cache
|
||||
apt:
|
||||
update_cache: yes
|
||||
force_apt_get: yes
|
||||
when: ansible_distribution in ['Debian', 'Ubuntu']
|
||||
|
||||
- name: Upgrade all installed packages to latest
|
||||
apt:
|
||||
name: "*"
|
||||
state: latest
|
||||
force_apt_get: yes
|
||||
become: yes
|
||||
when: ansible_distribution in ['Debian', 'Ubuntu']
|
||||
|
||||
- name: Dist-upgrade packages (handle removals and replacements)
|
||||
apt:
|
||||
upgrade: dist
|
||||
force_apt_get: yes
|
||||
become: yes
|
||||
when: ansible_distribution in ['Debian', 'Ubuntu']
|
||||
|
||||
- name: Install required packages
|
||||
apt:
|
||||
name: "{{ install_packages }}"
|
||||
state: present
|
||||
become: yes
|
||||
when: ansible_distribution in ['Debian', 'Ubuntu']
|
||||
register: apt_result
|
||||
|
||||
- name: Find all EXTERNALLY-MANAGED files under /usr/lib/python*
|
||||
find:
|
||||
paths: /usr/lib
|
||||
patterns: "EXTERNALLY-MANAGED"
|
||||
file_type: file
|
||||
recurse: yes
|
||||
register: externally_managed_files
|
||||
become: yes
|
||||
|
||||
- name: Delete EXTERNALLY-MANAGED files
|
||||
file:
|
||||
path: "{{ item.path }}"
|
||||
state: absent
|
||||
loop: "{{ externally_managed_files.files }}"
|
||||
when: externally_managed_files.matched > 0
|
||||
become: yes
|
17
ansible/tasks/pull_image.yml
Executable file
17
ansible/tasks/pull_image.yml
Executable file
@ -0,0 +1,17 @@
|
||||
---
|
||||
# Reusable snippet for pulling Docker images
|
||||
|
||||
- name: Set {{ image_name }} image reference
|
||||
set_fact:
|
||||
"{{ image_var }}_image_ref": "{{ image_ref }}"
|
||||
|
||||
- name: Ensure {{ image_name }} image is pulled
|
||||
community.docker.docker_image:
|
||||
name: "{{ image_ref }}"
|
||||
source: pull
|
||||
register: pulled_image
|
||||
|
||||
- name: Save image result under dynamic key
|
||||
set_fact:
|
||||
container_images: >-
|
||||
{{ container_images | default({}) | combine({ image_var: pulled_image }) }}
|
Reference in New Issue
Block a user