ansible-role-diun/tasks/main.yml

66 lines
1.5 KiB
YAML
Raw Normal View History

2023-03-01 10:56:33 +01:00
---
2023-03-01 11:35:03 +01:00
- name: "Create group"
ansible.builtin.group:
name: "{{ diun_user }}"
state: present
system: true
2023-03-01 10:56:33 +01:00
- name: "Create user"
ansible.builtin.user:
name: "{{ diun_user }}"
shell: /bin/false
create_home: false
password_lock: true
system: true
group: "{{ diun_user }}"
groups: docker
append: true
2023-03-01 10:56:33 +01:00
- name: "Get download URL"
ansible.builtin.shell:
2023-03-01 11:35:03 +01:00
cmd: curl -sL "{{ diun_github_api_url }}" | jq -r '.assets[] | select(.name|match("linux_amd64.tar.gz$")) | .browser_download_url'
2023-03-01 10:56:33 +01:00
changed_when: false
register: download_url
- name: "Unarchive binary"
ansible.builtin.unarchive:
2023-03-01 11:35:03 +01:00
src: "{{ download_url.stdout }}"
2023-03-01 10:56:33 +01:00
dest: "{{ diun_binary_path }}"
2023-03-01 11:35:03 +01:00
remote_src: true
include: diun
2023-03-01 10:56:33 +01:00
mode: 0755
2023-03-01 11:35:03 +01:00
extra_opts:
- "--strip=1"
- "--no-anchored"
2023-03-01 10:56:33 +01:00
- name: "Create directories"
ansible.builtin.file:
path: "{{ item }}"
2023-03-01 11:35:03 +01:00
state: directory
2023-03-01 10:56:33 +01:00
owner: "{{ diun_user }}"
group: "{{ diun_user }}"
mode: 0750
loop:
- "{{ diun_configuration_path }}"
- "{{ diun_home }}"
- name: "Copy configuration file"
ansible.builtin.template:
src: "{{ diun_configuration_file }}"
dest: "{{ diun_configuration_path }}"
mode: 0644
- name: "Copy service file"
ansible.builtin.template:
src: diun.service
dest: /etc/systemd/system/
mode: 0644
2023-03-01 11:35:03 +01:00
notify: restart diun
2023-03-01 10:56:33 +01:00
- name: "Enable service"
ansible.builtin.systemd:
name: diun
enabled: true
daemon_reload: true
state: started