summaryrefslogtreecommitdiffstats
path: root/roles
diff options
context:
space:
mode:
authorStefanie Forrester <dak1n1@users.noreply.github.com>2015-09-11 13:12:14 -0700
committerStefanie Forrester <dak1n1@users.noreply.github.com>2015-09-11 13:12:14 -0700
commitee97dd9be30d3d818cf4b8e86ace6e34ae5405ca (patch)
tree7cf0e7db757d3f538b18b96db4486665c77df7c7 /roles
parentda9326c388c4e6ea68aa9d0df348db237602cc51 (diff)
parentcdfd68f642c586d5d2bba7ff3c4721dc417717c1 (diff)
downloadopenshift-ee97dd9be30d3d818cf4b8e86ace6e34ae5405ca.tar.gz
openshift-ee97dd9be30d3d818cf4b8e86ace6e34ae5405ca.tar.bz2
openshift-ee97dd9be30d3d818cf4b8e86ace6e34ae5405ca.tar.xz
openshift-ee97dd9be30d3d818cf4b8e86ace6e34ae5405ca.zip
Merge pull request #569 from dak1n1/service_accounts
Set up service accounts for router and registry
Diffstat (limited to 'roles')
-rw-r--r--roles/openshift_serviceaccounts/tasks/main.yml26
-rw-r--r--roles/openshift_serviceaccounts/templates/serviceaccount.j24
2 files changed, 30 insertions, 0 deletions
diff --git a/roles/openshift_serviceaccounts/tasks/main.yml b/roles/openshift_serviceaccounts/tasks/main.yml
new file mode 100644
index 000000000..9665d0a72
--- /dev/null
+++ b/roles/openshift_serviceaccounts/tasks/main.yml
@@ -0,0 +1,26 @@
+- name: Create service account configs
+ template:
+ src: serviceaccount.j2
+ dest: "/tmp/{{ item }}-serviceaccount.yaml"
+ with_items: accounts
+
+- name: Create {{ item }} service account
+ command: >
+ {{ openshift.common.client_binary }} create -f "/tmp/{{ item }}-serviceaccount.yaml"
+ with_items: accounts
+ register: _sa_result
+ failed_when: "'serviceaccounts \"{{ item }}\" already exists' not in _sa_result.stderr and _sa_result.rc != 0"
+ changed_when: "'serviceaccounts \"{{ item }}\" already exists' not in _sa_result.stderr and _sa_result.rc == 0"
+
+- name: Get current security context constraints
+ shell: "{{ openshift.common.client_binary }} get scc privileged -o yaml > /tmp/scc.yaml"
+
+- name: Add security context constraint for {{ item }}
+ lineinfile:
+ dest: /tmp/scc.yaml
+ line: "- system:serviceaccount:default:{{ item }}"
+ insertafter: "^users:$"
+ with_items: accounts
+
+- name: Apply new scc rules for service accounts
+ command: "{{ openshift.common.client_binary }} replace -f /tmp/scc.yaml"
diff --git a/roles/openshift_serviceaccounts/templates/serviceaccount.j2 b/roles/openshift_serviceaccounts/templates/serviceaccount.j2
new file mode 100644
index 000000000..931e249f9
--- /dev/null
+++ b/roles/openshift_serviceaccounts/templates/serviceaccount.j2
@@ -0,0 +1,4 @@
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+ name: {{ item }}