Browse Source

combine configuration of init script into one task

Fabian Peter Hammerle 7 years ago
parent
commit
6c61654d7e
3 changed files with 17 additions and 10 deletions
  1. 5 10
      tasks/init-setup.yml
  2. 6 0
      vars/Debian.yml
  3. 6 0
      vars/RedHat.yml

+ 5 - 10
tasks/init-setup.yml

@@ -4,18 +4,13 @@
     path: "{{ gogs_user_home }}/{{ gogs_init_script_path }}"
     mode: 0755
 
-- name: Set path to Gogs in init script.
+- name: Configure Gogs init script.
   lineinfile:
     dest: "{{ gogs_user_home }}/{{ gogs_init_script_path }}"
-    line: "WORKINGDIR={{ gogs_user_home }}/gogs"
-    regexp: "^WORKINGDIR=.*"
-  notify: restart gogs
-
-- name: Set user in Gogs init script.
-  lineinfile:
-    dest: "{{ gogs_user_home }}/{{ gogs_init_script_path }}"
-    line: "USER={{ gogs_user }}"
-    regexp: "^USER=.*"
+    regexp: "{{ item.regexp }}"
+    line: "{{ item.line }}"
+    state: present
+  with_items: "{{ gogs_init_script_configuration_items }}"
   notify: restart gogs
 
 - name: Symlink Gogs binary and startup scripts.

+ 6 - 0
vars/Debian.yml

@@ -1,2 +1,8 @@
 ---
 gogs_init_script_path: gogs/scripts/init/debian/gogs
+
+gogs_init_script_configuration_items:
+- regexp: "^WORKINGDIR=.*"
+  line: "WORKINGDIR={{ gogs_user_home }}/gogs"
+- regexp: "^USER=.*"
+  line: "USER={{ gogs_user }}"

+ 6 - 0
vars/RedHat.yml

@@ -1,2 +1,8 @@
 ---
 gogs_init_script_path: gogs/scripts/init/centos/gogs
+
+gogs_init_script_configuration_items:
+- regexp: "^WORKINGDIR=.*"
+  line: "WORKINGDIR={{ gogs_user_home }}/gogs"
+- regexp: "^USER=.*"
+  line: "USER={{ gogs_user }}"