Browse Source

Merge branch 'fix/remove-directory-support' of ansible-roles/deploy-docker into master

tags/v1.2.0
lyz 1 year ago
parent
commit
a7b9bad811
6 changed files with 14 additions and 50 deletions
  1. 1
    1
      .yamllint
  2. 0
    2
      README.md
  3. 0
    6
      molecule/default/playbook.yml
  4. 2
    2
      molecule/default/requirements.yml
  5. 0
    29
      molecule/default/tests/test_default.py
  6. 11
    10
      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}}

+ 0
- 2
README.md View File

@@ -30,8 +30,6 @@ Role Variables
30 30
 * `docker_image`: If you want to download a docker image and not a git repository
31 31
 * `docker_image_tag`: Docker tag.
32 32
 * `docker_command`: Docker command used to launch the container.
33
-* `docker_data_directories`: List of directories where the data is going to be
34
-  saved on the host.
35 33
 * `remote_build`: Whether to build the docker remotely or locally [Default:
36 34
   `False`]
37 35
 

+ 0
- 6
molecule/default/playbook.yml View File

@@ -56,9 +56,6 @@
56 56
     remote_build: True
57 57
     docker_image: nginx
58 58
     service_name: image-nginx
59
-    docker_data_directories:
60
-      - "/root/docker/image-nginx/data"
61
-      - "/root/docker/image-nginx/auth"
62 59
     docker_registry: "docker-registry:5000"
63 60
     docker_registry_read: "{{ docker_registry }}"
64 61
     registry_user: testuser
@@ -77,9 +74,6 @@
77 74
     git_repository_extra_path: stable/stretch
78 75
     git_repository_tag: master
79 76
     service_name: git-nginx
80
-    docker_data_directories:
81
-      - "/root/docker/git-nginx/data"
82
-      - "/root/docker/git-nginx/auth"
83 77
     docker_registry: "docker-registry:5000"
84 78
     docker_registry_read: "{{ docker_registry }}"
85 79
     registry_user: testuser

+ 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

+ 0
- 29
molecule/default/tests/test_default.py View File

@@ -25,20 +25,6 @@ def test_required_pip_packages_exist(host, pip_package):
25 25
 
26 26
 # Test remotely build from image
27 27
 
28
-@pytest.mark.parametrize("directories", [
29
-    ("/root/docker/"),
30
-    ("/root/docker/image-nginx/data"),
31
-    ("/root/docker/image-nginx/auth"),
32
-])
33
-def test_required_directories_exist(host, directories):
34
-    with host.sudo():
35
-        directory = host.file(directories)
36
-        assert directory.exists
37
-        assert directory.user == 'root'
38
-        assert directory.group == 'root'
39
-        assert oct(directory.mode) == '0700'
40
-
41
-
42 28
 def test_build_nginx_image_is_downloaded(host):
43 29
     with host.sudo():
44 30
         registry_exist = host.check_output(
@@ -61,21 +47,6 @@ def test_build_nginx_is_working(host):
61 47
 
62 48
 # Test remotely build from git
63 49
 
64
-
65
-@pytest.mark.parametrize("directories", [
66
-    ("/root/docker/"),
67
-    ("/root/docker/git-nginx/data"),
68
-    ("/root/docker/git-nginx/auth"),
69
-])
70
-def test_required_directories_exist_for_git_build(host, directories):
71
-    with host.sudo():
72
-        directory = host.file(directories)
73
-        assert directory.exists
74
-        assert directory.user == 'root'
75
-        assert directory.group == 'root'
76
-        assert oct(directory.mode) == '0700'
77
-
78
-
79 50
 def test_image_nginx_image_is_downloaded(host):
80 51
     with host.sudo():
81 52
         registry_exist = host.check_output(

+ 11
- 10
tasks/main.yml View File

@@ -1,14 +1,4 @@
1 1
 ---
2
-- name: Create docker data directories
3
-  become: True
4
-  file:
5
-    path: "{{ item }}"
6
-    state: directory
7
-    owner: root
8
-    group: root
9
-    mode: 0700
10
-  with_items: "{{ docker_data_directories}}"
11
-
12 2
 - name: Log locally into private registry
13 3
   local_action:
14 4
     module: docker_login
@@ -98,6 +88,13 @@
98 88
     password: "{{ registry_password }}"
99 89
   when: remote_build == True
100 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
+
101 98
 - name: Clone git repository remotely
102 99
   git:
103 100
     repo: "{{ git_repository }}"
@@ -105,6 +102,7 @@
105 102
     version: "{{ git_repository_tag }}"
106 103
   when:
107 104
     - docker_image is not defined
105
+    - image_exists.rc != '0'
108 106
     - remote_build == True
109 107
 
110 108
 - name: Build docker image remotely and push it to a registry with tag latest
@@ -116,6 +114,7 @@
116 114
     push: yes
117 115
   when:
118 116
     - docker_image is not defined
117
+    - image_exists.rc != 0
119 118
     - remote_build == True
120 119
 
121 120
 - name: Build docker image remotely and push it to a registry with real tag
@@ -127,6 +126,7 @@
127 126
     push: yes
128 127
   when:
129 128
     - docker_image is not defined
129
+    - image_exists.rc != 0
130 130
     - remote_build == True
131 131
 
132 132
 - name: Build docker image remotely and push it to a registry
@@ -137,6 +137,7 @@
137 137
     push: yes
138 138
   when:
139 139
     - docker_image is not defined
140
+    - image_exists.rc != 0
140 141
     - remote_build == True
141 142
 
142 143
 - name: Download image remotely from public registry

Loading…
Cancel
Save