semaphore-test/test.yml
2024-08-26 21:09:01 +00:00

106 lines
3.2 KiB
YAML

---
- hosts: all
become: true
tasks:
- name: Update all servers (Debian/Ubuntu)
apt:
upgrade: dist
update_cache: yes
when: ansible_facts['os_family'] == "Debian"
- name: Make sure Zypper is installed (Debian/Ubuntu)
apt:
name: zypper
state: present
when: ansible_facts['os_family'] == "Debian"
- name: Install Docker (Debian/Ubuntu)
apt:
name:
- apt-transport-https
- ca-certificates
- curl
- gnupg-agent
- software-properties-common
state: present
when: ansible_facts['os_family'] == "Debian"
- name: Add Docker GPG key (Debian/Ubuntu)
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
when: ansible_facts['os_family'] == "Debian"
- name: Add Docker repository (Debian/Ubuntu)
apt_repository:
repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable
state: present
when: ansible_facts['os_family'] == "Debian"
- name: Install Docker (Debian/Ubuntu)
apt:
name:
- docker-ce
- docker-ce-cli
- containerd.io
state: present
when: ansible_facts['os_family'] == "Debian"
- name: Install Docker Compose (Debian/Ubuntu)
get_url:
url: https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64
dest: /usr/local/bin/docker-compose
mode: '0755'
when: ansible_facts['os_family'] == "Debian"
- name: See if a reboot is needed for Ubuntu/Debian pct
shell: "needs-restarting -r > /dev/null; echo $?"
register: needsRestartingDebian
changed_when: false
when: ansible_facts['os_family'] == "Debian"
- name: Debug needsRestartingDebian
debug:
msg: "Reboot needed: {{ needsRestartingDebian.stdout }}"
when: ansible_facts['os_family'] == "Debian"
- name: Reboot the server if necessary (Debian/Ubuntu)
reboot:
reboot_timeout: 600
when: ansible_facts['os_family'] == "Debian" and needsRestartingDebian.stdout == "1"
- name: Update all servers (Fedora)
dnf:
name: "*"
state: latest
when: ansible_facts['os_family'] == "RedHat"
- name: Make sure dnf-utils is installed
dnf:
name: dnf-utils
state: present
when: ansible_facts['os_family'] == "RedHat"
- name: Install Docker and Docker Compose (Fedora)
dnf:
name:
- docker
- docker-compose
state: present
when: ansible_facts['os_family'] == "RedHat"
- name: See if a reboot is needed (Fedora)
shell: "needs-restarting -r > /dev/null; echo $?"
register: needsRestartingFedora
changed_when: false
when: ansible_facts['os_family'] == "RedHat"
- name: Debug needsRestartingFedora
debug:
msg: "Reboot needed: {{ needsRestartingFedora.stdout }}"
when: ansible_facts['os_family'] == "RedHat"
- name: Reboot the server if necessary (Fedora)
reboot:
reboot_timeout: 600
when: ansible_facts['os_family'] == "RedHat" and needsRestartingFedora.stdout == "1"