From dd61f685b8aa85c559d3e91f96f586c96aba120a Mon Sep 17 00:00:00 2001 From: Antoine Legrand Date: Sat, 23 Jan 2016 18:01:18 +0100 Subject: [PATCH] AddUser Role --- cluster.yml | 1 + roles/adduser/defaults/main.yml | 15 +++++++++++++++ roles/adduser/tasks/main.yml | 13 +++++++++++++ roles/apps/k8s-kubedns | 2 +- roles/download/tasks/main.yml | 18 ------------------ 5 files changed, 30 insertions(+), 19 deletions(-) create mode 100644 roles/adduser/defaults/main.yml create mode 100644 roles/adduser/tasks/main.yml diff --git a/cluster.yml b/cluster.yml index faf0fea18..c0e23169a 100644 --- a/cluster.yml +++ b/cluster.yml @@ -1,6 +1,7 @@ --- - hosts: k8s-cluster roles: + - { role: adduser, tags: adduser } - { role: download, tags: download } - { role: kubernetes/preinstall, tags: preinstall } - { role: docker, tags: docker } diff --git a/roles/adduser/defaults/main.yml b/roles/adduser/defaults/main.yml new file mode 100644 index 000000000..6c5888827 --- /dev/null +++ b/roles/adduser/defaults/main.yml @@ -0,0 +1,15 @@ +--- +addusers: + - name: etcd + comment: "Etcd user" + createhome: yes + home: "/var/lib/etcd" + system: yes + shell: /bin/nologin + + - name: kube + comment: "Kubernetes user" + shell: /sbin/nologin + system: yes + group: "{{ kube_cert_group }}" + createhome: no \ No newline at end of file diff --git a/roles/adduser/tasks/main.yml b/roles/adduser/tasks/main.yml new file mode 100644 index 000000000..e082c7d2f --- /dev/null +++ b/roles/adduser/tasks/main.yml @@ -0,0 +1,13 @@ +- name: User | Create User Group + group: name={{item.group|default(item.name)}} system={{item.system|default(omit)}} + with_items: addusers + +- name: User | Create User + user: + comment: "{{item.comment|default(omit)}}" + createhome: "{{item.create_home|default(omit)}}" + group: "{{item.group|default(item.name)}}" + home: "{{item.home|default(omit)}}" + name: "{{item.name}}" + system: "{{item.system|default(omit)}}" + with_items: addusers diff --git a/roles/apps/k8s-kubedns b/roles/apps/k8s-kubedns index b5015aed8..d6df09a89 160000 --- a/roles/apps/k8s-kubedns +++ b/roles/apps/k8s-kubedns @@ -1 +1 @@ -Subproject commit b5015aed8ff5eed9c325911205cfbb23ad0e57be +Subproject commit d6df09a89721d98e2969a8abf29b4eb5e787fca6 diff --git a/roles/download/tasks/main.yml b/roles/download/tasks/main.yml index d83470bed..86271120f 100644 --- a/roles/download/tasks/main.yml +++ b/roles/download/tasks/main.yml @@ -1,22 +1,4 @@ --- -- name: certs | create system kube-cert groups - group: name={{ kube_cert_group }} state=present system=yes - -- name: Create system kube user - user: - name=kube - comment="Kubernetes user" - shell=/sbin/nologin - state=present - system=yes - groups={{ kube_cert_group }} - -- name: Create etcd user - user: - name: etcd - shell: /bin/nologin - home: /var/lib/etcd - - name: Create dest directories file: path={{local_release_dir}}/{{item.dest|dirname}} state=directory recurse=yes with_items: downloads