Skip to content

Instantly share code, notes, and snippets.

@Akkiesoft
Last active April 20, 2021 06:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Akkiesoft/b43d6631219cdf4d5f6d1f4862544d07 to your computer and use it in GitHub Desktop.
Save Akkiesoft/b43d6631219cdf4d5f6d1f4862544d07 to your computer and use it in GitHub Desktop.
しらんけどこんなんでいいんじゃない、しらんけど
- name: set timer
hosts: all
become: yes
vars:
name: mytimer
start_exec: /usr/bin/python3 /home/pi/bme280tozabbix.py
timer:
- OnUnitActiveSec=1min
tasks
- name: copy systemd service file
copy:
content: |
[Unit]
Description=timer service for {{ name }}
[Service]
Type=oneshot
ExecStart={{ start_exec }}
[Install]
WantedBy=default.target
dest: /etc/systemd/system/{{ name }}.service
mode: 0644
- name: copy systemd timer file
copy:
content: |
[Unit]
Description=timer for {{ name }}
[Timer]
{% for l in timer %}
{{ l }}
{% endfor %}
[Install]
WantedBy=timers.target
dest: /etc/systemd/system/{{ name }}.timer
mode: 0644
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment