Browse Source

Do not manage users/groups/services when chrooted

In containers, users/service management does not (and normally should
not) work with ansible user/group/service modules, so omit those.

Related-Bug: #1676373

Change-Id: If2fe57feb6961e367f4b99b810f87a92f8a7ac7c
Signed-off-by: Bogdan Dobrelya <bdobreli@redhat.com>
tags/2.1.1
Bogdan Dobrelya 11 months ago
parent
commit
6cc1853da1
2 changed files with 31 additions and 27 deletions
  1. 29
    27
      roles/provision/remote/tasks/main.yml
  2. 2
    0
      roles/provision/user/tasks/main.yml

+ 29
- 27
roles/provision/remote/tasks/main.yml View File

@@ -11,37 +11,39 @@
11 11
   args:
12 12
     creates: "{{ virt_host_key }}"
13 13
 
14
-- name: Ensure tuned is installed
15
-  package:
16
-    name: "tuned"
17
-    state: "present"
18
-  become: true
14
+- when: not chrooted|bool
15
+  block:
16
+    - name: Ensure tuned is installed
17
+      package:
18
+        name: "tuned"
19
+        state: "present"
20
+      become: true
19 21
 
20
-- name: Ensure tuned is enabled and started
21
-  service:
22
-    name: "tuned"
23
-    enabled: "yes"
24
-    state: "started"
25
-  become: true
22
+    - name: Ensure tuned is enabled and started
23
+      service:
24
+        name: "tuned"
25
+        enabled: "yes"
26
+        state: "started"
27
+      become: true
26 28
 
27
-- name: Retrieve current tuned profile
28
-  command: tuned-adm active
29
-  register: tuned
30
-  changed_when: False
29
+    - name: Retrieve current tuned profile
30
+      command: tuned-adm active
31
+      register: tuned
32
+      changed_when: False
31 33
 
32
-- name: Set tuned profile if not already set
33
-  command: tuned-adm profile "{{ tuned_profile }}"
34
-  become: true
35
-  when: tuned.stdout.find(tuned_profile) != 1
34
+    - name: Set tuned profile if not already set
35
+      command: tuned-adm profile "{{ tuned_profile }}"
36
+      become: true
37
+      when: tuned.stdout.find(tuned_profile) != 1
36 38
 
37
-# Create a non-root user on the target host.  This is the user that
38
-# will own the virtual infrastructure on which we deploy openstack.
39
-- name: Create non-root user
40
-  user:
41
-    name: "{{ non_root_user }}"
42
-    state: present
43
-    shell: /bin/bash
44
-  become: true
39
+    # Create a non-root user on the target host.  This is the user that
40
+    # will own the virtual infrastructure on which we deploy openstack.
41
+    - name: Create non-root user
42
+      user:
43
+        name: "{{ non_root_user }}"
44
+        state: present
45
+        shell: /bin/bash
46
+      become: true
45 47
 
46 48
 - name: Get the non-root user UID
47 49
   command: "id {{ non_root_user }} -u"

+ 2
- 0
roles/provision/user/tasks/main.yml View File

@@ -5,6 +5,7 @@
5 5
     name: "{{ non_root_group }}"
6 6
     state: present
7 7
   become: true
8
+  when: not chrooted|bool
8 9
 
9 10
 - name: Create non-root user
10 11
   user:
@@ -13,4 +14,5 @@
13 14
     state: present
14 15
     shell: /bin/bash
15 16
   become: true
17
+  when: not chrooted|bool
16 18
 

Loading…
Cancel
Save