diff --git a/group_vars/all b/group_vars/all index 5732509..88f2631 100644 --- a/group_vars/all +++ b/group_vars/all @@ -89,7 +89,6 @@ base_packages: - python-docs - python2-docs - screen - - units - python-pipenv - termdown @@ -292,6 +291,9 @@ syncthing: run_on: trusted mirrorlist: - run_on: trusted + run_on: trusted + +units: + run_on: trusted kernel_parameters: "quiet consoleblank=60 i915.enable_psr=2" diff --git a/playbook.yml b/playbook.yml index bf54f8e..4217576 100644 --- a/playbook.yml +++ b/playbook.yml @@ -78,6 +78,7 @@ - { role: goesimage, tags: ['goesimage'], when: "goesimage is defined" } - { role: syncthing, tags: ['syncthing'], when: "syncthing is defined" } - { role: mirrorlist, tags: ['mirrorlist'], when: "mirrorlist is defined" } + - { role: units, tags: ['units'], when: "units is defined" } - { role: logitech, tags: ['logitech'] } vars_prompt: - name: user_password diff --git a/roles/units/handlers/main.yml b/roles/units/handlers/main.yml new file mode 100644 index 0000000..9bfdb2f --- /dev/null +++ b/roles/units/handlers/main.yml @@ -0,0 +1,4 @@ +--- +- name: restart units_cur + service: name=units_cur.timer state=restarted + when: units.run_on == "all" diff --git a/roles/units/meta/main.yml b/roles/units/meta/main.yml new file mode 100644 index 0000000..6b0addd --- /dev/null +++ b/roles/units/meta/main.yml @@ -0,0 +1,4 @@ +--- +dependencies: + - { role: nmtrust } + - { role: systemd } diff --git a/roles/units/tasks/main.yml b/roles/units/tasks/main.yml new file mode 100644 index 0000000..69d05fe --- /dev/null +++ b/roles/units/tasks/main.yml @@ -0,0 +1,25 @@ +--- +- name: Install GNU Units + pacman: + name: units + state: present + +- name: Push GNU Units currency update service file + template: + src: units_cur.service.j2 + dest: /etc/systemd/system/units_cur.service + notify: + - reload systemd config + +- name: Push GNU Units currency update timer file + template: + src: units_cur.timer.j2 + dest: /etc/systemd/system/units_cur.timer + notify: + - reload systemd config + - restart units_cur + +- include_tasks: roles/nmtrust/tasks/unit.yml + vars: + unit: units_cur.timer + run_on: "{{ units.run_on }}" diff --git a/roles/units/templates/units_cur.service.j2 b/roles/units/templates/units_cur.service.j2 new file mode 100644 index 0000000..3c0b2d8 --- /dev/null +++ b/roles/units/templates/units_cur.service.j2 @@ -0,0 +1,10 @@ +# {{ ansible_managed }} +[Unit] +Description=GNU Units Currency Update Service +After=network.target + +[Service] +Type=oneshot +StandardOutput=syslog +StandardError=syslog +ExecStart=/usr/bin/units_cur{% if 'args' in units %} {{ units.args }}{% endif %} diff --git a/roles/units/templates/units_cur.timer.j2 b/roles/units/templates/units_cur.timer.j2 new file mode 100644 index 0000000..3b5d675 --- /dev/null +++ b/roles/units/templates/units_cur.timer.j2 @@ -0,0 +1,12 @@ +# {{ ansible_managed }} +[Unit] +Description=GNU Units Currency Update Timer + +[Timer] +OnCalendar=daily +Persistent=true +RandomizedDelaySec=3600 +Unit=units_cur.service + +[Install] +WantedBy=timers.target