From ddae30f4d80e0b0e2d6b2bc2cea5b3baa93edf4c Mon Sep 17 00:00:00 2001 From: Jayne Passmore Date: Thu, 24 Jul 2025 16:14:51 -0500 Subject: [PATCH 1/9] fixed reponame --- README.md | 6 +++--- defaults/main.yml | 2 +- handlers/main.yml | 2 +- tasks/main.yml | 2 +- tests/test.yml | 2 +- vars/main.yml | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4e8d65a..b9a9c16 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ role-ansible-update ========= -A brief description of the role goes here. +This role sets up a systemd service/timer and bash script to run ansible daily - staggers hosts hourly based on ansibleid Requirements ------------ @@ -23,8 +23,8 @@ Example Playbook Template Playbook creation should be handled by playbook-builder. To include role in a playbook, add one of these lines (changing version/branch as needed) to the template with other core entries: -role:mount:v1.0:core,mount -role:mount:testing:core,mount +role:ansible-update:v1.0:core,ansible +role:ansible-update:testing:core,ansible License ------- diff --git a/defaults/main.yml b/defaults/main.yml index a0eb46b..9aee32a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,3 +1,3 @@ #SPDX-License-Identifier: MIT-0 --- -# defaults file for ${REPO_NAME} +# defaults file for ansible-update diff --git a/handlers/main.yml b/handlers/main.yml index 192bcab..50efea0 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,3 +1,3 @@ #SPDX-License-Identifier: MIT-0 --- -# handlers file for ${REPO_NAME} +# handlers file for ansible-update diff --git a/tasks/main.yml b/tasks/main.yml index 0482006..df830a9 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,3 +1,3 @@ #SPDX-License-Identifier: MIT-0 --- -# tasks file for ${REPO_NAME} +# tasks file for ansible-update diff --git a/tests/test.yml b/tests/test.yml index a1c8646..910f1c2 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -3,4 +3,4 @@ - hosts: localhost remote_user: root roles: - - ${REPO_NAME} + - ansible-update diff --git a/vars/main.yml b/vars/main.yml index f31a73e..1c9af58 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,3 +1,3 @@ #SPDX-License-Identifier: MIT-0 --- -# vars file for ${REPO_NAME} +# vars file for ansible-update From 0f40ca47c5101a5548c50daaa601699fd4bb572b Mon Sep 17 00:00:00 2001 From: Jayne Passmore Date: Thu, 24 Jul 2025 16:18:39 -0500 Subject: [PATCH 2/9] added ansible-update stuff --- files/run_ansible.service | 10 ++++++++++ files/run_ansible.sh | 0 tasks/main.yml | 24 ++++++++++++++++++++++++ templates/run_ansible.timer | 9 +++++++++ 4 files changed, 43 insertions(+) create mode 100644 files/run_ansible.service create mode 100644 files/run_ansible.sh create mode 100644 templates/run_ansible.timer diff --git a/files/run_ansible.service b/files/run_ansible.service new file mode 100644 index 0000000..b102a7c --- /dev/null +++ b/files/run_ansible.service @@ -0,0 +1,10 @@ +[Unit] +Description=Runs ansible playbook + +[Service] +Type=oneshot +RemainAfterExit=no +ExecStart=/scripts/run_ansible.sh + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/files/run_ansible.sh b/files/run_ansible.sh new file mode 100644 index 0000000..e69de29 diff --git a/tasks/main.yml b/tasks/main.yml index df830a9..bac49f6 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,3 +1,27 @@ #SPDX-License-Identifier: MIT-0 --- # tasks file for ansible-update +- name: deploy ansible update script + ansible.builtin.template: + src: templates/ansible-update.sh + dest: /scripts/ansible-update.sh + mode: '0754' + +- name: deploy ansible update service + ansible.builtin.copy: + src: files/ansible-update.service + dest: /usr/lib/systemd/system/ansible-update.service + mode: '0644' + +- name: deploy ansible update timer + ansible.builtin.copy: + src: files/ansible-update.timer + dest: /usr/lib/systemd/system/cansible-update.timer + mode: '0644' + +- name: ensure ansible update script is running + service: + name: ansible-update.timer + state: started + daemon_reload: true + enabled: yes \ No newline at end of file diff --git a/templates/run_ansible.timer b/templates/run_ansible.timer new file mode 100644 index 0000000..acc5260 --- /dev/null +++ b/templates/run_ansible.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Runs run ansible playbook once per day (hour is determined based on ansible id) + +[Timer] +OnCalendar=*-*-* {{ansible_machine_id | int(base=16) % 24}}:00:00 +Unit=certbot-renewal.service + +[Install] +WantedBy=multi-user.target From 9dac6ebe3f80f893a48c27a3e2aea36a032cc0ac Mon Sep 17 00:00:00 2001 From: Jayne Passmore Date: Thu, 24 Jul 2025 16:28:16 -0500 Subject: [PATCH 3/9] renamed run_ansible to run-ansible, added script contents --- files/{run_ansible.service => run-ansible.service} | 2 +- files/run-ansible.sh | 4 ++++ files/run_ansible.sh | 0 templates/{run_ansible.timer => run-ansible.timer} | 0 4 files changed, 5 insertions(+), 1 deletion(-) rename files/{run_ansible.service => run-ansible.service} (78%) create mode 100644 files/run-ansible.sh delete mode 100644 files/run_ansible.sh rename templates/{run_ansible.timer => run-ansible.timer} (100%) diff --git a/files/run_ansible.service b/files/run-ansible.service similarity index 78% rename from files/run_ansible.service rename to files/run-ansible.service index b102a7c..9925eaa 100644 --- a/files/run_ansible.service +++ b/files/run-ansible.service @@ -4,7 +4,7 @@ Description=Runs ansible playbook [Service] Type=oneshot RemainAfterExit=no -ExecStart=/scripts/run_ansible.sh +ExecStart=/scripts/run-ansible.sh [Install] WantedBy=multi-user.target \ No newline at end of file diff --git a/files/run-ansible.sh b/files/run-ansible.sh new file mode 100644 index 0000000..7792fdd --- /dev/null +++ b/files/run-ansible.sh @@ -0,0 +1,4 @@ + +#! /bin/bash +cd /ansible +/bin/bash build_ansible.sh \ No newline at end of file diff --git a/files/run_ansible.sh b/files/run_ansible.sh deleted file mode 100644 index e69de29..0000000 diff --git a/templates/run_ansible.timer b/templates/run-ansible.timer similarity index 100% rename from templates/run_ansible.timer rename to templates/run-ansible.timer From ae80f12285c3114cb26b4782694ce5c0fb30031d Mon Sep 17 00:00:00 2001 From: Jayne Passmore Date: Thu, 24 Jul 2025 16:48:20 -0500 Subject: [PATCH 4/9] fixed names --- tasks/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index bac49f6..cc0f974 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,8 +2,8 @@ --- # tasks file for ansible-update - name: deploy ansible update script - ansible.builtin.template: - src: templates/ansible-update.sh + ansible.builtin.copy: + src: files/ansible-update.sh dest: /scripts/ansible-update.sh mode: '0754' @@ -14,8 +14,8 @@ mode: '0644' - name: deploy ansible update timer - ansible.builtin.copy: - src: files/ansible-update.timer + ansible.builtin.template: + src: templates/ansible-update.timer dest: /usr/lib/systemd/system/cansible-update.timer mode: '0644' From 02df81f5388c19f0fb304cfe53069352a186726e Mon Sep 17 00:00:00 2001 From: Jayne Passmore Date: Thu, 24 Jul 2025 16:49:35 -0500 Subject: [PATCH 5/9] fixed names --- files/{run-ansible.service => ansible-update.service} | 0 files/{run-ansible.sh => ansible-update.sh} | 0 templates/{run-ansible.timer => ansible-update.timer} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename files/{run-ansible.service => ansible-update.service} (100%) rename files/{run-ansible.sh => ansible-update.sh} (100%) rename templates/{run-ansible.timer => ansible-update.timer} (100%) diff --git a/files/run-ansible.service b/files/ansible-update.service similarity index 100% rename from files/run-ansible.service rename to files/ansible-update.service diff --git a/files/run-ansible.sh b/files/ansible-update.sh similarity index 100% rename from files/run-ansible.sh rename to files/ansible-update.sh diff --git a/templates/run-ansible.timer b/templates/ansible-update.timer similarity index 100% rename from templates/run-ansible.timer rename to templates/ansible-update.timer From dc90568cced98780c200bf3a82c7097636f345de Mon Sep 17 00:00:00 2001 From: Jayne Passmore Date: Thu, 24 Jul 2025 16:54:32 -0500 Subject: [PATCH 6/9] fixed names --- tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index cc0f974..4d855b8 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -16,7 +16,7 @@ - name: deploy ansible update timer ansible.builtin.template: src: templates/ansible-update.timer - dest: /usr/lib/systemd/system/cansible-update.timer + dest: /usr/lib/systemd/system/ansible-update.timer mode: '0644' - name: ensure ansible update script is running From 3c5ae9ba26d30b9f32bbdf1fb92c0993446ebf56 Mon Sep 17 00:00:00 2001 From: Jayne Passmore Date: Thu, 24 Jul 2025 17:05:01 -0500 Subject: [PATCH 7/9] fixed names --- files/ansible-update.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/ansible-update.service b/files/ansible-update.service index 9925eaa..4ba1436 100644 --- a/files/ansible-update.service +++ b/files/ansible-update.service @@ -4,7 +4,7 @@ Description=Runs ansible playbook [Service] Type=oneshot RemainAfterExit=no -ExecStart=/scripts/run-ansible.sh +ExecStart=/scripts/ansible-update.sh [Install] WantedBy=multi-user.target \ No newline at end of file From 0c61e0131fd27689fcaa5dc9253783d2b6ff9674 Mon Sep 17 00:00:00 2001 From: Jayne Passmore Date: Thu, 24 Jul 2025 17:05:38 -0500 Subject: [PATCH 8/9] fixed names --- templates/ansible-update.timer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/ansible-update.timer b/templates/ansible-update.timer index acc5260..79ada07 100644 --- a/templates/ansible-update.timer +++ b/templates/ansible-update.timer @@ -3,7 +3,7 @@ Description=Runs run ansible playbook once per day (hour is determined based on [Timer] OnCalendar=*-*-* {{ansible_machine_id | int(base=16) % 24}}:00:00 -Unit=certbot-renewal.service +Unit=ansible-update.service [Install] WantedBy=multi-user.target From 34e7ce2d719c674ce60fee3e0a26bf3b1b8a347b Mon Sep 17 00:00:00 2001 From: Jayne Passmore Date: Thu, 24 Jul 2025 17:11:10 -0500 Subject: [PATCH 9/9] fix service --- files/ansible-update.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/ansible-update.service b/files/ansible-update.service index 4ba1436..936d5f4 100644 --- a/files/ansible-update.service +++ b/files/ansible-update.service @@ -4,7 +4,7 @@ Description=Runs ansible playbook [Service] Type=oneshot RemainAfterExit=no -ExecStart=/scripts/ansible-update.sh +ExecStart=/bin/bash /scripts/ansible-update.sh [Install] WantedBy=multi-user.target \ No newline at end of file