From 727ab17a644d52105746e18c301cf733b1181507 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 31 Jul 2023 23:44:54 +0200 Subject: move Ansible files to src/ --- src/roles/common/handlers/main.yml | 24 ++++++++++++++++++++++++ src/roles/common/tasks/main.yml | 17 +++++++++++++++++ src/roles/common/tasks/tool.yml | 8 ++++++++ 3 files changed, 49 insertions(+) create mode 100644 src/roles/common/handlers/main.yml create mode 100644 src/roles/common/tasks/main.yml create mode 100644 src/roles/common/tasks/tool.yml (limited to 'src/roles/common') diff --git a/src/roles/common/handlers/main.yml b/src/roles/common/handlers/main.yml new file mode 100644 index 0000000..4942957 --- /dev/null +++ b/src/roles/common/handlers/main.yml @@ -0,0 +1,24 @@ +- name: Reboot + ansible.builtin.reboot: + args: + # On my trusty old Raspberry Pi 1 Model B+, /proc/sys/kernel/random/boot_id + # can sometimes stay the same between reboots. Apparently, not enough + # entropy or something. + boot_time_command: uptime -s + # Another option is `who -s`. This option requires Ansible 2.10 or later. + + # 5 minutes is plenty. + reboot_timeout: 300 + # Don't reboot yourself accidentally: + when: 'ansible_env["SSH_CLIENT"].split()[0] not in ansible_all_ipv4_addresses' + become: true + listen: reboot + +- name: Wait for connectivity + # One of the nodes is the VPN server connecting all the other nodes, wait + # until all of them are back up: + ansible.builtin.wait_for_connection: + args: + # 5 minutes is plenty. + timeout: 300 + listen: reboot diff --git a/src/roles/common/tasks/main.yml b/src/roles/common/tasks/main.yml new file mode 100644 index 0000000..fb0eaed --- /dev/null +++ b/src/roles/common/tasks/main.yml @@ -0,0 +1,17 @@ +- name: Check available tools + ansible.builtin.include_tasks: tool.yml + loop: + - apt + - docker + - flatpak + - pacman + - rate-mirrors + - snap + - vagrant + - yay + +- name: Check if /etc is versioned + become: true + ansible.builtin.stat: + path: /etc/.git/config + register: etc_versioned diff --git a/src/roles/common/tasks/tool.yml b/src/roles/common/tasks/tool.yml new file mode 100644 index 0000000..48d0acc --- /dev/null +++ b/src/roles/common/tasks/tool.yml @@ -0,0 +1,8 @@ +- name: "Check for {{ item }}" + ansible.builtin.command: "{{ item }} --version" + register: cmd_result + changed_when: false + failed_when: false + +- name: "Set fact about {{ item }}" + ansible.builtin.set_fact: "has_{{ item | replace('-', '_') }}={{ cmd_result.rc == 0 }}" -- cgit v1.2.3