Move fast and break things

I'll just leave this here…

#! /usr/bin/env ansible-playbook
- hosts: OpenBSD:!dns
  gather_facts: False
  tasks:
    - name: run sysupgrade
      ansible.builtin.command:
        cmd: 'sysupgrade -s'
      ignore_errors: yes
      async: 3600
      poll: 0

- hosts: dns:!ansible_orchestrator
  gather_facts: False
  serial: 1
  tasks:
    - name: run sysupgrade -n
      ansible.builtin.command:
        cmd: 'sysupgrade -ns'

    - name: check for /bsd.upgrade
      ansible.builtin.stat:
        path: /bsd.upgrade
      register: upgrade_pending

    - name: reboot and wait for host to return
      block:
        - name: reboot
          ansible.builtin.command:
            cmd: reboot
          ignore_errors: yes
          async: 3600
          poll: 0
        - name: wait for ssh to go away
          ansible.builtin.wait_for:
            host: '{{ (ansible_ssh_host|default(ansible_host))|default(inventory_hostname) }}'
            port: 22
            state: stopped
            delay: 10
          vars:
            ansible_connection: local

        - name: wait for DNS to come back.
          ansible.builtin.wait_for:
            state: started
            host: '{{ (ansible_ssh_host|default(ansible_host))|default(inventory_hostname) }}'
            port: 53
            delay: 10
          vars:
            ansible_connection: local
      when: upgrade_pending.stat.exists

- hosts: ansible_orchestrator
  gather_facts: False
  tasks:
    - name: run sysupgrade
      ansible.builtin.command:
        cmd: 'sysupgrade -s'
      ignore_errors: yes

Published: 2023-02-02