Move add user task to an import_tasks task so that we can actually notify it, use systemd daemon reloads in a copuple places

This commit is contained in:
Salt 2020-04-30 11:54:27 -05:00
parent ab51654a1b
commit 21d3d8c410
3 changed files with 38 additions and 30 deletions

View File

@ -2,35 +2,9 @@
# vim:ft=ansible:
---
- name: restart gitea
service:
systemd:
daemon_reload: yes
name: gitea.service
state: restarted
- name: gitea add default user
block:
- name: Create user
command:
argv:
- /usr/local/bin/gitea
- admin
- create-user
- --username
- "{{ gitea_admin_username }}"
- --password
- "{{ gitea_admin_password }}"
- --email
- "{{ gitea_admin_email }}"
- --config
- /etc/gitea/app.ini
- name: Promote user to admin
command:
argv:
- /usr/bin/mysql
- gitea
- -u
- gitea
- -p
- "{{ gitea_mysql_password }}"
- -e
- 'UPDATE user SET is_admin = 1 WHERE name = {{ gitea_admin_username }};'
become: yes
become_user: git
import_tasks: tasks/add_default_user.yml

View File

@ -0,0 +1,33 @@
#!/usr/bin/ansible-playbook
# vim:ft=ansible:
---
- name: Create user
command:
argv:
- /usr/local/bin/gitea
- admin
- create-user
- --username
- "{{ gitea_admin_username }}"
- --password
- "{{ gitea_admin_password }}"
- --email
- "{{ gitea_admin_email }}"
- --config
- /etc/gitea/app.ini
become: yes
become_user: git
- name: Promote user to admin
command:
argv:
- /usr/bin/mysql
- gitea
- -u
- gitea
- -p
- "{{ gitea_mysql_password }}"
- -e
- 'UPDATE user SET is_admin = 1 WHERE name = {{ gitea_admin_username }};'
become: yes
become_user: git

View File

@ -108,7 +108,8 @@
dest: "/etc/systemd/system/gitea.service"
notify: restart gitea
- name: Start and enable service
service:
systemd:
daemon_reload: yes
name: "gitea.service"
enabled: yes
state: "started"