diff --git a/README.md b/README.md index 2e5cd645..fd8ea067 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,8 @@ Click on the name of a plugin or module to view that content's documentation: - [k8s_info](https://docs.ansible.com/ansible/latest/modules/k8s_info_module.html) - [k8s_scale](https://docs.ansible.com/ansible/latest/modules/k8s_scale_module.html) - [k8s_service](https://docs.ansible.com/ansible/latest/modules/k8s_service_module.html) - - [helm_cli](https://docs.ansible.com/ansible/latest/modules/helm_cli_module.html) - - [helm_cli_info](https://docs.ansible.com/ansible/latest/modules/helm_cli_info_module.html) + - [helm](https://docs.ansible.com/ansible/latest/modules/helm_module.html) + - [helm_info](https://docs.ansible.com/ansible/latest/modules/helm_info_module.html) ## Installation and Usage diff --git a/molecule/default/roles/helm/tasks/run_test.yml b/molecule/default/roles/helm/tasks/run_test.yml index f772ad14..a67a1e8f 100644 --- a/molecule/default/roles/helm/tasks/run_test.yml +++ b/molecule/default/roles/helm/tasks/run_test.yml @@ -1,12 +1,12 @@ --- -- name: Ensure helm is not install +- name: Ensure helm is not installed file: path: "{{ item }}" state: absent with_items: - "/tmp/helm" -- name: Check failed if helm is not install +- name: Check failed if helm is not installed include_tasks: test_helm_not_installed.yml - name: "Install {{ helm_version }}" diff --git a/molecule/default/roles/helm/tasks/test_helm_not_installed.yml b/molecule/default/roles/helm/tasks/test_helm_not_installed.yml index 63cfb394..0832dcb0 100644 --- a/molecule/default/roles/helm/tasks/test_helm_not_installed.yml +++ b/molecule/default/roles/helm/tasks/test_helm_not_installed.yml @@ -1,6 +1,6 @@ --- -- name: Failed test when helm is not install - helm_cli: +- name: Failed test when helm is not installed + helm: binary_path: "{{ helm_binary}}_fake" name: test chart_ref: "{{ chart_test }}" diff --git a/molecule/default/roles/helm/tasks/tests_chart.yml b/molecule/default/roles/helm/tasks/tests_chart.yml index 5ddbf0c7..eb6d518f 100644 --- a/molecule/default/roles/helm/tasks/tests_chart.yml +++ b/molecule/default/roles/helm/tasks/tests_chart.yml @@ -6,24 +6,24 @@ name: "{{ helm_namespace }}" wait: true -- name: Check helm_cli_info empty - helm_cli_info: - binary_path: "{{ helm_binary}}" +- name: Check helm_info empty + helm_info: + binary_path: "{{ helm_binary }}" name: test namespace: "{{ helm_namespace }}" register: empty_info -- name: "Assert that no chart are installed with helm_cli_info" +- name: "Assert that no charts are installed with helm_info" assert: that: - empty_info.status is undefined - name: "Install {{ chart_test }} from {{ source }}" - helm_cli: - binary_path: "{{ helm_binary}}" + helm: + binary_path: "{{ helm_binary }}" name: test chart_ref: "{{ chart_source }}" - chart_version: "{{ chart_source_version | default(omit)}}" + chart_version: "{{ chart_source_version | default(omit) }}" namespace: "{{ helm_namespace }}" register: install @@ -34,25 +34,25 @@ - install.status.chart == "{{ chart_test }}-{{ chart_test_version }}" - install.status.status | lower == 'deployed' -- name: Check helm_cli_info content - helm_cli_info: - binary_path: "{{ helm_binary}}" +- name: Check helm_info content + helm_info: + binary_path: "{{ helm_binary }}" name: test namespace: "{{ helm_namespace }}" register: content_info -- name: "Assert that {{ chart_test }} is installed from {{ source }} with helm_cli_info" +- name: "Assert that {{ chart_test }} is installed from {{ source }} with helm_info" assert: that: - content_info.status.chart == "{{ chart_test }}-{{ chart_test_version }}" - content_info.status.status | lower == 'deployed' - name: Check idempotency - helm_cli: - binary_path: "{{ helm_binary}}" + helm: + binary_path: "{{ helm_binary }}" name: test chart_ref: "{{ chart_source }}" - chart_version: "{{ chart_source_version | default(omit)}}" + chart_version: "{{ chart_source_version | default(omit) }}" namespace: "{{ helm_namespace }}" register: install @@ -64,11 +64,11 @@ - install.status.status | lower == 'deployed' - name: "Add vars to {{ chart_test }} from {{ source }}" - helm_cli: - binary_path: "{{ helm_binary}}" + helm: + binary_path: "{{ helm_binary }}" name: test chart_ref: "{{ chart_source }}" - chart_version: "{{ chart_source_version | default(omit)}}" + chart_version: "{{ chart_source_version | default(omit) }}" namespace: "{{ helm_namespace }}" values: "{{ chart_test_values }}" register: install @@ -81,12 +81,12 @@ - install.status.chart == "{{ chart_test }}-{{ chart_test_version }}" - "install.status['values'].revisionHistoryLimit == 0" -- name: Check idempotency after add vars - helm_cli: - binary_path: "{{ helm_binary}}" +- name: Check idempotency after adding vars + helm: + binary_path: "{{ helm_binary }}" name: test chart_ref: "{{ chart_source }}" - chart_version: "{{ chart_source_version | default(omit)}}" + chart_version: "{{ chart_source_version | default(omit) }}" namespace: "{{ helm_namespace }}" values: "{{ chart_test_values }}" register: install @@ -100,11 +100,11 @@ - "install.status['values'].revisionHistoryLimit == 0" - name: "Remove Vars to {{ chart_test }} from {{ source }}" - helm_cli: - binary_path: "{{ helm_binary}}" + helm: + binary_path: "{{ helm_binary }}" name: test chart_ref: "{{ chart_source }}" - chart_version: "{{ chart_source_version | default(omit)}}" + chart_version: "{{ chart_source_version | default(omit) }}" namespace: "{{ helm_namespace }}" register: install @@ -116,16 +116,16 @@ - install.status.chart == "{{ chart_test }}-{{ chart_test_version }}" - install.status['values'] == {} -- name: Check idempotency after remove vars - helm_cli: - binary_path: "{{ helm_binary}}" +- name: Check idempotency after removing vars + helm: + binary_path: "{{ helm_binary }}" name: test chart_ref: "{{ chart_source }}" - chart_version: "{{ chart_source_version | default(omit)}}" + chart_version: "{{ chart_source_version | default(omit) }}" namespace: "{{ helm_namespace }}" register: install -- name: Assert idempotency after remove vars +- name: Assert idempotency after removing vars assert: that: - install is not changed @@ -134,11 +134,11 @@ - install.status['values'] == {} - name: "Upgrade {{ chart_test }} from {{ source }}" - helm_cli: - binary_path: "{{ helm_binary}}" + helm: + binary_path: "{{ helm_binary }}" name: test chart_ref: "{{ chart_source_upgrade | default(chart_source) }}" - chart_version: "{{ chart_source_version_upgrade | default(omit)}}" + chart_version: "{{ chart_source_version_upgrade | default(omit) }}" namespace: "{{ helm_namespace }}" register: install @@ -150,11 +150,11 @@ - install.status.chart == "{{ chart_test }}-{{ chart_test_version_upgrade }}" - name: Check idempotency after upgrade - helm_cli: - binary_path: "{{ helm_binary}}" + helm: + binary_path: "{{ helm_binary }}" name: test chart_ref: "{{ chart_source_upgrade | default(chart_source) }}" - chart_version: "{{ chart_source_version_upgrade | default(omit)}}" + chart_version: "{{ chart_source_version_upgrade | default(omit) }}" namespace: "{{ helm_namespace }}" register: install @@ -166,21 +166,21 @@ - install.status.chart == "{{ chart_test }}-{{ chart_test_version_upgrade }}" - name: "Remove {{ chart_test }} from {{ source }}" - helm_cli: - binary_path: "{{ helm_binary}}" + helm: + binary_path: "{{ helm_binary }}" state: absent name: test namespace: "{{ helm_namespace }}" register: install -- name: "Assert that {{ chart_test }} chart is remove from {{ source }}" +- name: "Assert that {{ chart_test }} chart is removed from {{ source }}" assert: that: - install is changed - name: Check idempotency after remove - helm_cli: - binary_path: "{{ helm_binary}}" + helm: + binary_path: "{{ helm_binary }}" state: absent name: test namespace: "{{ helm_namespace }}" diff --git a/molecule/default/roles/helm/templates/tiller-clusterRoleBinding.yml b/molecule/default/roles/helm/templates/tiller-clusterRoleBinding.yml deleted file mode 100644 index 4ac25c80..00000000 --- a/molecule/default/roles/helm/templates/tiller-clusterRoleBinding.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: tiller -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: "{{ tiller_cluster_role }}" -subjects: - - kind: ServiceAccount - name: tiller - namespace: "{{ tiller_namespace }}" diff --git a/molecule/default/roles/helm/templates/tiller-sa.yml b/molecule/default/roles/helm/templates/tiller-sa.yml deleted file mode 100644 index 7adbd3c9..00000000 --- a/molecule/default/roles/helm/templates/tiller-sa.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -kind: ServiceAccount -apiVersion: v1 -metadata: - name: tiller - namespace: "{{ tiller_namespace }}" diff --git a/plugins/modules/helm_cli.py b/plugins/modules/helm.py similarity index 99% rename from plugins/modules/helm_cli.py rename to plugins/modules/helm.py index a469d88d..7f5b125d 100644 --- a/plugins/modules/helm_cli.py +++ b/plugins/modules/helm.py @@ -12,7 +12,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1', DOCUMENTATION = ''' --- -module: helm_cli +module: helm short_description: Manages Kubernetes packages with the Helm package manager @@ -138,7 +138,7 @@ EXAMPLES = ''' shell: "helm repo add stable https://kubernetes-charts.storage.googleapis.com" - name: Deploy latest version of Grafana chart inside monitoring namespace with values - helm_cli: + helm: name: test chart_ref: stable/grafana release_namespace: monitoring @@ -146,14 +146,14 @@ EXAMPLES = ''' replicas: 2 - name: Deploy Grafana chart on 5.0.12 with values loaded from template - helm_cli: + helm: name: test chart_ref: stable/grafana chart_version: 5.0.12 values: "{{ lookup('template', 'somefile.yaml') | from_yaml }}" - name: Remove test release and waiting suppression ending - helm_cli: + helm: name: test state: absent wait: true @@ -165,14 +165,14 @@ EXAMPLES = ''' dest: /tmp/helm_repo - name: Deploy Grafana chart from local path - helm_cli: + helm: name: test chart_ref: /tmp/helm_repo/stable/grafana release_namespace: monitoring # From url - name: Deploy Grafana chart on 5.0.12 from url - helm_cli: + helm: name: test chart_ref: "https://kubernetes-charts.storage.googleapis.com/grafana-5.0.12.tgz" release_namespace: monitoring diff --git a/plugins/modules/helm_cli_info.py b/plugins/modules/helm_info.py similarity index 99% rename from plugins/modules/helm_cli_info.py rename to plugins/modules/helm_info.py index 2b513b02..07697aa0 100644 --- a/plugins/modules/helm_cli_info.py +++ b/plugins/modules/helm_info.py @@ -12,7 +12,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1', DOCUMENTATION = ''' --- -module: helm_cli_info +module: helm_info short_description: Get informations from Helm package deployed inside the cluster description: - Get informations (values, states, ...) from Helm package deployed inside the cluster @@ -55,7 +55,7 @@ options: EXAMPLES = ''' - name: Deploy latest version of Grafana chart inside monitoring namespace - helm_cli_info: + helm_info: name: test release_namespace: monitoring '''