Last active
February 19, 2018 03:32
-
-
Save karayok/1011fc5b1f1cb90e9b644d63e98ede9c to your computer and use it in GitHub Desktop.
Ansible role to add settings of myappd.service to /etc/systemd/system/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# role/systemd/tasks/main.yml | |
- name: Add myappd.service | |
become: yes | |
template: | |
src: 'myappd.service.j2' | |
dest: '/etc/systemd/system/myappd.service' | |
mode: 0644 | |
tags: systemd | |
- name: Reload myappd.service | |
become: yes | |
command: systemctl daemon-reload | |
tags: systemd | |
- name: enable myappd.service | |
command: systemctl enable myappd.service | |
become: yes | |
- name: Restart myapp deamon | |
become: yes | |
service: | |
name: myappd.service | |
state: restarted | |
tags: systemd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# role/systemd/templates/myappd.service.j2 | |
[Unit] | |
Description=My Task Scheduling Script | |
[Service] | |
Type=simple | |
KillMode=control-group | |
ExecStart=/home/bar/myapp/venv/bin/python3 /home/bar/myapp/run.py | |
Restart=on-failure | |
User=bar | |
Group=foo | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment