Browse Source

* Updated dependencies of requirements.yml

* Increased yamllint lines length
* Add idempotence to the role
tags/v1.2.0^2
Lyz 1 year ago
parent
commit
df27cc6167
Signed by: Lyz <lyz@riseup.net> GPG Key ID: 6C7D7C1612CDE02F
3 changed files with 14 additions and 3 deletions
  1. 1
    1
      .yamllint
  2. 2
    2
      molecule/default/requirements.yml
  3. 11
    0
      tasks/main.yml

+ 1
- 1
.yamllint View File

@@ -1,3 +1,3 @@
1 1
 extends: relaxed
2 2
 truthy: disable
3
-rules: {line-length: {max: 125}}
3
+rules: {line-length: {max: 373}}

+ 2
- 2
molecule/default/requirements.yml View File

@@ -1,4 +1,4 @@
1 1
 - src: git+https://git.digitales.cslabrecha.org/ansible-roles/docker.git
2
-  version: v1.0.1
2
+  version: v1.1.0
3 3
 - src: git+https://git.digitales.cslabrecha.org/ansible-roles/docker-registry.git
4
-  version: feature/26
4
+  version: v1.0.0

+ 11
- 0
tasks/main.yml View File

@@ -88,6 +88,13 @@
88 88
     password: "{{ registry_password }}"
89 89
   when: remote_build == True
90 90
 
91
+- name: Test if image exists
92
+  become: True
93
+  command: docker inspect --type=image "{{ docker_registry }}/{{ service_name }}"
94
+  register: image_exists
95
+  changed_when: false
96
+  failed_when: false
97
+
91 98
 - name: Clone git repository remotely
92 99
   git:
93 100
     repo: "{{ git_repository }}"
@@ -95,6 +102,7 @@
95 102
     version: "{{ git_repository_tag }}"
96 103
   when:
97 104
     - docker_image is not defined
105
+    - image_exists.rc != '0'
98 106
     - remote_build == True
99 107
 
100 108
 - name: Build docker image remotely and push it to a registry with tag latest
@@ -106,6 +114,7 @@
106 114
     push: yes
107 115
   when:
108 116
     - docker_image is not defined
117
+    - image_exists.rc != 0
109 118
     - remote_build == True
110 119
 
111 120
 - name: Build docker image remotely and push it to a registry with real tag
@@ -117,6 +126,7 @@
117 126
     push: yes
118 127
   when:
119 128
     - docker_image is not defined
129
+    - image_exists.rc != 0
120 130
     - remote_build == True
121 131
 
122 132
 - name: Build docker image remotely and push it to a registry
@@ -127,6 +137,7 @@
127 137
     push: yes
128 138
   when:
129 139
     - docker_image is not defined
140
+    - image_exists.rc != 0
130 141
     - remote_build == True
131 142
 
132 143
 - name: Download image remotely from public registry

Loading…
Cancel
Save