From ccbb2ee3aed8ae4b71e84f818c5261b91a4a65a1 Mon Sep 17 00:00:00 2001 From: Antoine Legrand <2t.antoine@gmail.com> Date: Wed, 7 Sep 2016 20:02:06 +0200 Subject: [PATCH] App deployer plugins --- cluster.yml | 2 +- inventory/group_vars/all.yml | 6 +----- .../{ => ansible}/library/kube.py | 0 .../{ => ansible}/tasks/main.yaml | 0 .../{ => ansible}/templates/kubedns-rc.yml | 0 .../{ => ansible}/templates/kubedns-svc.yml | 0 roles/kubernetes-apps/helm/.gitkeep | 0 roles/kubernetes-apps/helm/tasks/main.yml | 2 ++ .../kubernetes-apps/kpm/library}/kpm.py | 0 roles/kubernetes-apps/kpm/tasks/main.yaml | 20 +++++++++++++++++++ roles/kubernetes-apps/meta/main.yaml | 3 +++ 11 files changed, 27 insertions(+), 6 deletions(-) rename roles/kubernetes-apps/{ => ansible}/library/kube.py (100%) rename roles/kubernetes-apps/{ => ansible}/tasks/main.yaml (100%) rename roles/kubernetes-apps/{ => ansible}/templates/kubedns-rc.yml (100%) rename roles/kubernetes-apps/{ => ansible}/templates/kubedns-svc.yml (100%) create mode 100644 roles/kubernetes-apps/helm/.gitkeep create mode 100644 roles/kubernetes-apps/helm/tasks/main.yml rename {library => roles/kubernetes-apps/kpm/library}/kpm.py (100%) create mode 100644 roles/kubernetes-apps/kpm/tasks/main.yaml create mode 100644 roles/kubernetes-apps/meta/main.yaml diff --git a/cluster.yml b/cluster.yml index 45d4183b9..091bdc103 100644 --- a/cluster.yml +++ b/cluster.yml @@ -25,4 +25,4 @@ - hosts: kube-master[0] roles: - - {role: kubernetes-apps, tags: apps} + - { role: kubernetes-apps, tags: apps } \ No newline at end of file diff --git a/inventory/group_vars/all.yml b/inventory/group_vars/all.yml index 547a9d612..59c572198 100644 --- a/inventory/group_vars/all.yml +++ b/inventory/group_vars/all.yml @@ -130,9 +130,5 @@ dns_server: "{{ kube_service_addresses|ipaddr('net')|ipaddr(2)|ipaddr('address') docker_options: "--insecure-registry={{ kube_service_addresses }}" # default packages to install within the cluster -kpm_packages: - - name: kube-system/kubedns - namespace: kube-system - variables: - cluster_ip: "{{skydns_server}}" +kpm_packages: [] # - name: kube-system/grafana diff --git a/roles/kubernetes-apps/library/kube.py b/roles/kubernetes-apps/ansible/library/kube.py similarity index 100% rename from roles/kubernetes-apps/library/kube.py rename to roles/kubernetes-apps/ansible/library/kube.py diff --git a/roles/kubernetes-apps/tasks/main.yaml b/roles/kubernetes-apps/ansible/tasks/main.yaml similarity index 100% rename from roles/kubernetes-apps/tasks/main.yaml rename to roles/kubernetes-apps/ansible/tasks/main.yaml diff --git a/roles/kubernetes-apps/templates/kubedns-rc.yml b/roles/kubernetes-apps/ansible/templates/kubedns-rc.yml similarity index 100% rename from roles/kubernetes-apps/templates/kubedns-rc.yml rename to roles/kubernetes-apps/ansible/templates/kubedns-rc.yml diff --git a/roles/kubernetes-apps/templates/kubedns-svc.yml b/roles/kubernetes-apps/ansible/templates/kubedns-svc.yml similarity index 100% rename from roles/kubernetes-apps/templates/kubedns-svc.yml rename to roles/kubernetes-apps/ansible/templates/kubedns-svc.yml diff --git a/roles/kubernetes-apps/helm/.gitkeep b/roles/kubernetes-apps/helm/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/roles/kubernetes-apps/helm/tasks/main.yml b/roles/kubernetes-apps/helm/tasks/main.yml new file mode 100644 index 000000000..9fd691ddd --- /dev/null +++ b/roles/kubernetes-apps/helm/tasks/main.yml @@ -0,0 +1,2 @@ +--- +- debug: msg="No helm charts" diff --git a/library/kpm.py b/roles/kubernetes-apps/kpm/library/kpm.py similarity index 100% rename from library/kpm.py rename to roles/kubernetes-apps/kpm/library/kpm.py diff --git a/roles/kubernetes-apps/kpm/tasks/main.yaml b/roles/kubernetes-apps/kpm/tasks/main.yaml new file mode 100644 index 000000000..7e88cc30d --- /dev/null +++ b/roles/kubernetes-apps/kpm/tasks/main.yaml @@ -0,0 +1,20 @@ +--- +- name: install kpm + pip: + name: "kpm" + state: "present" + version: "0.16.1" + when: kpm_packages | length > 0 + +- name: manage kubernetes applications + kpm: + namespace: "{{item.namespace | default(kpm_namespace | default('default'))}}" + registry: "{{item.registry | default(kpm_registry | default('https://api.kpm.sh'))}}" + state: "{{item.state | default(omit)}}" + version: "{{item.version | default(omit)}}" + variables: "{{item.variables | default(omit)}}" + name: "{{item.name}}" + with_items: "{{kpm_packages}}" + register: kpmresults + environment: + PATH: "{{ ansible_env.PATH }}:{{ bin_dir }}" diff --git a/roles/kubernetes-apps/meta/main.yaml b/roles/kubernetes-apps/meta/main.yaml new file mode 100644 index 000000000..496517d72 --- /dev/null +++ b/roles/kubernetes-apps/meta/main.yaml @@ -0,0 +1,3 @@ +dependencies: + - {role: kubernetes-apps/ansible, tags: apps} + - {role: kubernetes-apps/kpm, tags: [apps, kpm]}