Browse Source

* Added ugly grade idempotency

* Added docker_user
tags/v1.2.0^2^2
Lyz 1 year ago
parent
commit
dc322c9bca
Signed by: Lyz <lyz@riseup.net> GPG Key ID: 6C7D7C1612CDE02F
2 changed files with 15 additions and 2 deletions
  1. 2
    0
      defaults/main.yml
  2. 13
    2
      tasks/main.yml

+ 2
- 0
defaults/main.yml View File

@@ -9,5 +9,7 @@ docker_registry_url:
9 9
 docker_registry_read:
10 10
 registry_user:
11 11
 registry_password:
12
+docker_user: root
13
+docker_group: "{{ docker_user }}"
12 14
 docker_image_tag: "{{ git_repository_tag }}"
13 15
 docker_command:

+ 13
- 2
tasks/main.yml View File

@@ -1,11 +1,18 @@
1 1
 ---
2
+- name: Create docker service user
3
+  become: True
4
+  user:
5
+    name: "{{ docker_user }}"
6
+    groups: "{{ docker_group }}"
7
+  when: docker_user != 'root'
8
+
2 9
 - name: Create docker data directories
3 10
   become: True
4 11
   file:
5 12
     path: "{{ item }}"
6 13
     state: directory
7
-    owner: root
8
-    group: root
14
+    owner: "{{ docker_user }}"
15
+    group: "{{ docker_user }}"
9 16
     mode: 0700
10 17
   with_items: "{{ docker_data_directories}}"
11 18
 
@@ -103,6 +110,7 @@
103 110
     repo: "{{ git_repository }}"
104 111
     dest: "{{ git_repository_destination }}"
105 112
     version: "{{ git_repository_tag }}"
113
+  register: git_cloned
106 114
   when:
107 115
     - docker_image is not defined
108 116
     - remote_build == True
@@ -117,6 +125,7 @@
117 125
   when:
118 126
     - docker_image is not defined
119 127
     - remote_build == True
128
+    - git_cloned.changed == True
120 129
 
121 130
 - name: Build docker image remotely and push it to a registry with real tag
122 131
   become: True
@@ -128,6 +137,7 @@
128 137
   when:
129 138
     - docker_image is not defined
130 139
     - remote_build == True
140
+    - git_cloned.changed == True
131 141
 
132 142
 - name: Build docker image remotely and push it to a registry
133 143
   become: True
@@ -138,6 +148,7 @@
138 148
   when:
139 149
     - docker_image is not defined
140 150
     - remote_build == True
151
+    - git_cloned.changed == True
141 152
 
142 153
 - name: Download image remotely from public registry
143 154
   become: True

Loading…
Cancel
Save