diff --git a/docs/roles/debian/ansible.md b/docs/roles/debian/ansible.md index b7dfe0dbc..f50de4929 100644 --- a/docs/roles/debian/ansible.md +++ b/docs/roles/debian/ansible.md @@ -19,6 +19,7 @@ ce_ansible: enabled: true # create systemd timer to auto-upgrade Ansible command: "{{ _venv_path }}/bin/python3 -m pip install --upgrade ansible" # if you set venv_path above then set it here too on_calendar: "*-*-* 01:30:00" # see systemd.time documentation - https://www.freedesktop.org/software/systemd/man/latest/systemd.time.html#Calendar%20Events + #timer_name: upgrade_ansible linters: enabled: true # will not install linters if false, installing linters breaks cloud-init diff --git a/docs/roles/debian/ce_deploy.md b/docs/roles/debian/ce_deploy.md index d020663ab..f9e55b15f 100644 --- a/docs/roles/debian/ce_deploy.md +++ b/docs/roles/debian/ce_deploy.md @@ -15,6 +15,7 @@ ce_deploy: venv_path: "/home/{{ _ce_deploy.username }}/ansible" venv_command: /usr/bin/python3 -m venv install_username: "{{ _ce_deploy.username }}" + upgrade_timer_name: upgrade_ce_deploy_ansible # Other ce-deploy settings. new_user: true # set to false if user already exists or is ephemeral, e.g. an LDAP user key_name: id_rsa.pub # existing users may have a key of a different name diff --git a/docs/roles/debian/ce_provision.md b/docs/roles/debian/ce_provision.md index e8f83ea13..dba324120 100644 --- a/docs/roles/debian/ce_provision.md +++ b/docs/roles/debian/ce_provision.md @@ -16,6 +16,7 @@ ce_provision: venv_path: "/home/{{ _ce_provision.username }}/ansible" venv_command: /usr/bin/python3 -m venv install_username: "{{ _ce_provision.username }}" + upgrade_timer_name: upgrade_ce_provision_ansible # Other ce-provision settings. username: "{{ _ce_provision.username }}" new_user: true # set to false if user already exists or is ephemeral, e.g. an LDAP user diff --git a/docs/roles/debian/ldap_server.md b/docs/roles/debian/ldap_server.md index 7fb78adfb..6514e4779 100644 --- a/docs/roles/debian/ldap_server.md +++ b/docs/roles/debian/ldap_server.md @@ -107,6 +107,7 @@ ldap_server: # reload_command: restart # reload: # - slapd + # on_calendar: "Mon *-*-* 04:00:00" replication: host: "" # host must be present in config/hosts for ce-provision, leave empty if no replication is desired port: "636" diff --git a/roles/_meta/common_base/meta/main.yml b/roles/_meta/common_base/meta/main.yml index 9e3635fa6..7a79993e8 100644 --- a/roles/_meta/common_base/meta/main.yml +++ b/roles/_meta/common_base/meta/main.yml @@ -51,5 +51,6 @@ dependencies: enabled: true command: "/home/{{ ce_provision.username }}/ansible/bin/python3 -m pip install --upgrade ansible" on_calendar: "*-*-* 01:30:00" + timer_name: upgrade_ansible linters: enabled: false diff --git a/roles/debian/ansible/README.md b/roles/debian/ansible/README.md index b7dfe0dbc..f50de4929 100644 --- a/roles/debian/ansible/README.md +++ b/roles/debian/ansible/README.md @@ -19,6 +19,7 @@ ce_ansible: enabled: true # create systemd timer to auto-upgrade Ansible command: "{{ _venv_path }}/bin/python3 -m pip install --upgrade ansible" # if you set venv_path above then set it here too on_calendar: "*-*-* 01:30:00" # see systemd.time documentation - https://www.freedesktop.org/software/systemd/man/latest/systemd.time.html#Calendar%20Events + #timer_name: upgrade_ansible linters: enabled: true # will not install linters if false, installing linters breaks cloud-init diff --git a/roles/debian/ansible/defaults/main.yml b/roles/debian/ansible/defaults/main.yml index f58a026b0..949bb48b7 100644 --- a/roles/debian/ansible/defaults/main.yml +++ b/roles/debian/ansible/defaults/main.yml @@ -8,5 +8,6 @@ ce_ansible: enabled: true # create systemd timer to auto-upgrade Ansible command: "{{ _venv_path }}/bin/python3 -m pip install --upgrade ansible" # if you set venv_path above then set it here too on_calendar: "*-*-* 01:30:00" # see systemd.time documentation - https://www.freedesktop.org/software/systemd/man/latest/systemd.time.html#Calendar%20Events + #timer_name: upgrade_ansible linters: enabled: true # will not install linters if false, installing linters breaks cloud-init diff --git a/roles/debian/ansible/tasks/main.yml b/roles/debian/ansible/tasks/main.yml index 56d1d94f2..a34b6d0fe 100644 --- a/roles/debian/ansible/tasks/main.yml +++ b/roles/debian/ansible/tasks/main.yml @@ -68,12 +68,17 @@ content: "export PATH=$PATH:{{ ce_ansible.venv_path | default(_venv_path) }}/bin" dest: "/etc/profile.d/ansible-path.sh" +- name: Build systemd timer variables string. + ansible.builtin.set_fact: + _timer: "{'{{ ce_ansible.upgrade.timer_name | default(_ce_ansible_timer_name) }}': { timer_command: '{{ ce_ansible.upgrade.command }}', timer_OnCalendar: '{{ ce_ansible.upgrade.on_calendar }}' }}" + +- name: Turn the timer string into a dictionary. + ansible.builtin.set_fact: + _timer: "{{ _timer.splitlines()|map('from_yaml')|list }}" + - name: Create systemd timer to upgrade Ansible. ansible.builtin.include_role: name: contrib/systemd_timers vars: - timers: - upgrade_ansible: - timer_command: "{{ ce_ansible.upgrade.command }}" - timer_OnCalendar: "{{ ce_ansible.upgrade.on_calendar }}" + timers: "{{ _timer }}" when: ce_ansible.upgrade.enabled diff --git a/roles/debian/ce_deploy/README.md b/roles/debian/ce_deploy/README.md index d020663ab..f9e55b15f 100644 --- a/roles/debian/ce_deploy/README.md +++ b/roles/debian/ce_deploy/README.md @@ -15,6 +15,7 @@ ce_deploy: venv_path: "/home/{{ _ce_deploy.username }}/ansible" venv_command: /usr/bin/python3 -m venv install_username: "{{ _ce_deploy.username }}" + upgrade_timer_name: upgrade_ce_deploy_ansible # Other ce-deploy settings. new_user: true # set to false if user already exists or is ephemeral, e.g. an LDAP user key_name: id_rsa.pub # existing users may have a key of a different name diff --git a/roles/debian/ce_deploy/defaults/main.yml b/roles/debian/ce_deploy/defaults/main.yml index 52bd86415..1dc9ba5b3 100644 --- a/roles/debian/ce_deploy/defaults/main.yml +++ b/roles/debian/ce_deploy/defaults/main.yml @@ -7,6 +7,7 @@ ce_deploy: venv_path: "/home/{{ _ce_deploy.username }}/ansible" venv_command: /usr/bin/python3 -m venv install_username: "{{ _ce_deploy.username }}" + upgrade_timer_name: upgrade_ce_deploy_ansible # Other ce-deploy settings. new_user: true # set to false if user already exists or is ephemeral, e.g. an LDAP user key_name: id_rsa.pub # existing users may have a key of a different name diff --git a/roles/debian/ce_deploy/tasks/main.yml b/roles/debian/ce_deploy/tasks/main.yml index a9d607723..ae5395780 100644 --- a/roles/debian/ce_deploy/tasks/main.yml +++ b/roles/debian/ce_deploy/tasks/main.yml @@ -133,6 +133,7 @@ _venv_path: "{{ ce_deploy.venv_path }}" _venv_command: "{{ ce_deploy.venv_command }}" _install_username: "{{ ce_deploy.install_username }}" + _ce_ansible_timer_name: "{{ ce_deploy.upgrade_timer_name }}" - name: Install Ansible. ansible.builtin.include_role: diff --git a/roles/debian/ce_provision/README.md b/roles/debian/ce_provision/README.md index e8f83ea13..dba324120 100644 --- a/roles/debian/ce_provision/README.md +++ b/roles/debian/ce_provision/README.md @@ -16,6 +16,7 @@ ce_provision: venv_path: "/home/{{ _ce_provision.username }}/ansible" venv_command: /usr/bin/python3 -m venv install_username: "{{ _ce_provision.username }}" + upgrade_timer_name: upgrade_ce_provision_ansible # Other ce-provision settings. username: "{{ _ce_provision.username }}" new_user: true # set to false if user already exists or is ephemeral, e.g. an LDAP user diff --git a/roles/debian/ce_provision/defaults/main.yml b/roles/debian/ce_provision/defaults/main.yml index 4c266e3e0..8f8d508cf 100644 --- a/roles/debian/ce_provision/defaults/main.yml +++ b/roles/debian/ce_provision/defaults/main.yml @@ -8,6 +8,7 @@ ce_provision: venv_path: "/home/{{ _ce_provision.username }}/ansible" venv_command: /usr/bin/python3 -m venv install_username: "{{ _ce_provision.username }}" + upgrade_timer_name: upgrade_ce_provision_ansible # Other ce-provision settings. username: "{{ _ce_provision.username }}" new_user: true # set to false if user already exists or is ephemeral, e.g. an LDAP user diff --git a/roles/debian/ce_provision/tasks/main.yml b/roles/debian/ce_provision/tasks/main.yml index ca59d5928..0f4edeab1 100644 --- a/roles/debian/ce_provision/tasks/main.yml +++ b/roles/debian/ce_provision/tasks/main.yml @@ -141,6 +141,7 @@ _venv_path: "{{ ce_provision.venv_path }}" _venv_command: "{{ ce_provision.venv_command }}" _install_username: "{{ ce_provision.install_username }}" + _ce_ansible_timer_name: "{{ ce_provision.upgrade_timer_name }}" - name: Install Ansible. ansible.builtin.include_role: diff --git a/roles/debian/ldap_server/README.md b/roles/debian/ldap_server/README.md index 7fb78adfb..6514e4779 100644 --- a/roles/debian/ldap_server/README.md +++ b/roles/debian/ldap_server/README.md @@ -107,6 +107,7 @@ ldap_server: # reload_command: restart # reload: # - slapd + # on_calendar: "Mon *-*-* 04:00:00" replication: host: "" # host must be present in config/hosts for ce-provision, leave empty if no replication is desired port: "636" diff --git a/roles/debian/ldap_server/defaults/main.yml b/roles/debian/ldap_server/defaults/main.yml index 981d6b995..8178688a0 100644 --- a/roles/debian/ldap_server/defaults/main.yml +++ b/roles/debian/ldap_server/defaults/main.yml @@ -41,6 +41,7 @@ ldap_server: # reload_command: restart # reload: # - slapd + # on_calendar: "Mon *-*-* 04:00:00" replication: host: "" # host must be present in config/hosts for ce-provision, leave empty if no replication is desired port: "636"