Browse Source

* Change user/group to uid/gid

* Update docker version of requirements to install docker-py
tags/v1.2.0^2^2
Lyz 1 year ago
parent
commit
25527b553d
Signed by: Lyz <lyz@riseup.net> GPG Key ID: 6C7D7C1612CDE02F

+ 2
- 2
defaults/main.yml View File

@@ -9,7 +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
+docker_uid: 0
13
+docker_gid: "{{ docker_uid }}"
14 14
 docker_image_tag: "{{ git_repository_tag }}"
15 15
 docker_command:

+ 1
- 1
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 4
   version: v1.0.0

+ 4
- 2
molecule/nginx-user/playbook.yml View File

@@ -63,7 +63,8 @@
63 63
     docker_registry_read: "{{ docker_registry }}"
64 64
     registry_user: testuser
65 65
     registry_password: testpassword
66
-    docker_user: nginx
66
+    docker_uid: 101
67
+    docker_gid: 101
67 68
     docker_image_tag: latest
68 69
     docker_command: /usr/bin/docker run --rm -i --name "{{ service_name }}" -p 8080:80 "{{ docker_registry_read }}/{{ service_name }}"
69 70
   roles:
@@ -85,7 +86,8 @@
85 86
     docker_registry_read: "{{ docker_registry }}"
86 87
     registry_user: testuser
87 88
     registry_password: testpassword
88
-    docker_user: nginx
89
+    docker_uid: 101
90
+    docker_gid: 101
89 91
     docker_image_tag: latest
90 92
     docker_command: /usr/bin/docker run --rm -i --name "{{ service_name }}" -p 8081:80 "{{ docker_registry_read }}/{{ service_name }}"
91 93
   roles:

+ 1
- 1
molecule/nginx-user/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 4
   version: v1.0.0

+ 4
- 8
molecule/nginx-user/tests/test_default.py View File

@@ -23,10 +23,6 @@ def test_required_pip_packages_exist(host, pip_package):
23 23
     assert pip_package in pip_packages
24 24
 
25 25
 
26
-def test_user_nginx_exist(host):
27
-    assert host.user('nginx').name == 'nginx'
28
-    assert host.user('nginx').shell == '/usr/sbin/nologin'
29
-
30 26
 # Test remotely build from image
31 27
 
32 28
 
@@ -38,8 +34,8 @@ def test_required_directories_exist(host, directories):
38 34
     with host.sudo():
39 35
         directory = host.file(directories)
40 36
         assert directory.exists
41
-        assert directory.user == 'nginx'
42
-        assert directory.group == 'nginx'
37
+        assert directory.uid == 101
38
+        assert directory.gid == 101
43 39
         assert oct(directory.mode) == '0700'
44 40
 
45 41
 
@@ -74,8 +70,8 @@ def test_required_directories_exist_for_git_build(host, directories):
74 70
     with host.sudo():
75 71
         directory = host.file(directories)
76 72
         assert directory.exists
77
-        assert directory.user == 'nginx'
78
-        assert directory.group == 'nginx'
73
+        assert directory.uid == 101
74
+        assert directory.gid == 101
79 75
         assert oct(directory.mode) == '0700'
80 76
 
81 77
 

+ 2
- 20
tasks/main.yml View File

@@ -1,29 +1,11 @@
1 1
 ---
2
-- name: Create docker service group
3
-  become: True
4
-  group:
5
-    name: "{{ docker_group }}"
6
-    state: present
7
-  when:
8
-    - docker_group != 'root'
9
-
10
-- name: Create docker service user
11
-  become: True
12
-  user:
13
-    name: "{{ docker_user }}"
14
-    group: "{{ docker_group }}"
15
-    shell: /usr/sbin/nologin
16
-  when:
17
-    - docker_user != 'root'
18
-    - docker_group != 'root'
19
-
20 2
 - name: Create docker data directories
21 3
   become: True
22 4
   file:
23 5
     path: "{{ item }}"
24 6
     state: directory
25
-    owner: "{{ docker_user }}"
26
-    group: "{{ docker_group }}"
7
+    owner: "{{ docker_uid }}"
8
+    group: "{{ docker_gid }}"
27 9
     mode: 0700
28 10
   with_items: "{{ docker_data_directories}}"
29 11
 

Loading…
Cancel
Save