Browse Source

fix SELinux bit of docker role

Blaine Story 3 năm trước cách đây
mục cha
commit
b6fbd681c2
2 tập tin đã thay đổi với 19 bổ sung16 xóa
  1. 19 7
      roles/docker/tasks/create_dirs.yml
  2. 0 9
      roles/docker/tasks/main.yml

+ 19 - 7
roles/docker/tasks/create_dirs.yml

@@ -4,12 +4,24 @@
     path: "{{ item }}"
   register: container_dir
 
-- name: Create {{ item }}
-  file:
-    path: "{{ item }}"
-    state: directory
-    owner: "{{ container_user }}"
-    group: "{{ container_group }}"
-    mode: '0770'
+
+- block:
+    - name: Create {{ item }}
+      file:
+        path: "{{ item }}"
+        state: directory
+        owner: "{{ container_user }}"
+        group: "{{ container_group }}"
+        mode: '0770'
+
+    - name: Modify SELinux contexts for {{ item }}
+      sefcontext:
+        target: "{{ item }}(/.*)?"
+        setype: container_file_t
+        state: present
+
+    - name: Apply SELinux contexts to {{ item }}
+      shell:
+        cmd: restorecon -r "{{ item }}"
   when:
     - not container_dir.stat.exists

+ 0 - 9
roles/docker/tasks/main.yml

@@ -94,15 +94,6 @@
   loop_control:
     label: "{{ item }}"
 
-#- name: Modify SELinux contexts for container directories
-#  sefcontext:
-#    target: "{{ item | quote }}(/.*)?"
-#    setype: container_file_t
-#    state: present
-#  with_items:
-#    - "{{ persistent_container_dirs }}"
-#  notify: Apply SELinux contexts
-
 - name: Copy systemd service file
   template:
     src: service.j2