2025-12-25 10:24:55 +01:00
2025-12-25 10:24:55 +01:00
2025-12-25 10:22:57 +01:00
2025-12-25 10:22:57 +01:00
2025-12-25 10:22:57 +01:00

Semaphore playbooks

Einleitung

Playbooks

Update Ubuntu

---
- name: Update ubuserver
  hosts: ubuserver
  become: true
  tasks:
    # Update and install the base software
    - name: Update and upgrade
      ansible.builtin.apt:
        autoclean: yes
        update_cache: yes
        cache_valid_time: 3600
        upgrade: dist

    - name: Remove dependencies that are no longer required and purge their configuration files
      ansible.builtin.apt:
        autoremove: yes
        purge: true

    - command: apt clean
      #become: yes

    - name: Check if a reboot is needed for Debian and Ubuntu boxes
      register: reboot_required_file
      stat: path=/var/run/reboot-required get_md5=no

    - name: Reboot the box if kernel updated
      reboot:
        msg: "Reboot initiated by Ansible for kernel updates"
        connect_timeout: 5
        reboot_timeout: 300
        pre_reboot_delay: 0
        post_reboot_delay: 30
        test_command: uptime
      when: reboot_required_file.stat.exists

Test cmd

Hier mal bissl was zum Spielen:

---
- name: Spielwiese
  hosts: dockerserver
  tasks:
    - name: Container present
      docker_container:
        name: ansible-mysql-1
        state: present
        image: mysql:8.0
        command: sleep infinity
    
    - name: Stop a container
      docker_container:
        name: ansible-mysql-1
        state: stopped
Description
No description provided
Readme Apache-2.0 31 KiB