diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2023-08-04 11:20:03 +0200 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2023-08-04 11:20:03 +0200 |
commit | c182c4dc6694ee6e7f49cfa91f5d02ea306c072d (patch) | |
tree | 82a8889418a1d64312db4e76080dd14014ff70f0 /roles/apt | |
parent | initial commit (diff) | |
download | infra-ansible-c182c4dc6694ee6e7f49cfa91f5d02ea306c072d.tar.gz infra-ansible-c182c4dc6694ee6e7f49cfa91f5d02ea306c072d.zip |
import some common roles
Diffstat (limited to '')
-rw-r--r-- | roles/apt/handlers/main.yml | 16 | ||||
-rw-r--r-- | roles/apt/tasks/main.yml | 20 |
2 files changed, 36 insertions, 0 deletions
diff --git a/roles/apt/handlers/main.yml b/roles/apt/handlers/main.yml new file mode 100644 index 0000000..625a8af --- /dev/null +++ b/roles/apt/handlers/main.yml @@ -0,0 +1,16 @@ +- name: Reboot + ansible.builtin.reboot: + args: + # 3 minutes is plenty. + reboot_timeout: 180 + # 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 + ansible.builtin.wait_for_connection: + args: + # 3 minutes is plenty. + timeout: 180 + listen: reboot diff --git a/roles/apt/tasks/main.yml b/roles/apt/tasks/main.yml new file mode 100644 index 0000000..f26a1f7 --- /dev/null +++ b/roles/apt/tasks/main.yml @@ -0,0 +1,20 @@ +- name: Upgrade packages + become: true + ansible.builtin.apt: + install_recommends: false + update_cache: true + upgrade: dist + notify: reboot + +- name: Reboot if necessary + ansible.builtin.meta: flush_handlers + +- name: Clean up dependencies + become: true + ansible.builtin.apt: + autoremove: true + purge: true + notify: reboot + +- name: Reboot if necessary + ansible.builtin.meta: flush_handlers |