2019-03-04 10:15:04 +01:00
|
|
|
- set_fact:
|
|
|
|
rpfx: "{{ resource_group | hash('md5') | truncate(8, True, '') }}"
|
|
|
|
|
|
|
|
- name: Find available k8s version
|
|
|
|
azure_rm_aks_version:
|
|
|
|
location: eastus
|
|
|
|
register: versions
|
|
|
|
|
2018-05-17 01:08:27 +02:00
|
|
|
- name: Create an AKS instance (check mode)
|
|
|
|
azure_rm_aks:
|
2019-03-04 10:15:04 +01:00
|
|
|
name: "aks{{ rpfx }}"
|
2018-05-17 01:08:27 +02:00
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
location: eastus
|
2019-03-04 10:15:04 +01:00
|
|
|
dns_prefix: "aks{{ rpfx }}"
|
|
|
|
kubernetes_version: "{{ versions.azure_aks_versions[0] }}"
|
2018-05-17 01:08:27 +02:00
|
|
|
service_principal:
|
2019-03-01 03:25:49 +01:00
|
|
|
client_id: "{{ azure_client_id }}"
|
|
|
|
client_secret: "{{ azure_secret }}"
|
2018-05-17 01:08:27 +02:00
|
|
|
linux_profile:
|
|
|
|
admin_username: azureuser
|
|
|
|
ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
|
|
|
|
agent_pool_profiles:
|
|
|
|
- name: default
|
|
|
|
count: 1
|
|
|
|
vm_size: Standard_DS1_v2
|
2019-03-04 10:15:04 +01:00
|
|
|
enable_rbac: yes
|
2018-05-17 01:08:27 +02:00
|
|
|
check_mode: yes
|
|
|
|
|
|
|
|
- name: Check there is no AKS created
|
|
|
|
azure_rm_aks_facts:
|
2019-03-04 10:15:04 +01:00
|
|
|
name: "aks{{ rpfx }}"
|
2018-05-17 01:08:27 +02:00
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
register: fact
|
|
|
|
|
|
|
|
- name: Check there is no AKS created
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "fact.aks | length == 0"
|
|
|
|
|
|
|
|
- name: Create an AKS instance
|
|
|
|
azure_rm_aks:
|
2019-03-04 10:15:04 +01:00
|
|
|
name: "aks{{ rpfx }}"
|
2018-05-17 01:08:27 +02:00
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
location: eastus
|
2019-03-04 10:15:04 +01:00
|
|
|
dns_prefix: "aks{{ rpfx }}"
|
|
|
|
kubernetes_version: "{{ versions.azure_aks_versions[0] }}"
|
2018-05-17 01:08:27 +02:00
|
|
|
service_principal:
|
2019-03-01 03:25:49 +01:00
|
|
|
client_id: "{{ azure_client_id }}"
|
|
|
|
client_secret: "{{ azure_secret }}"
|
2018-05-17 01:08:27 +02:00
|
|
|
linux_profile:
|
|
|
|
admin_username: azureuser
|
|
|
|
ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
|
|
|
|
agent_pool_profiles:
|
|
|
|
- name: default
|
|
|
|
count: 1
|
|
|
|
vm_size: Standard_DS1_v2
|
2018-10-29 07:36:38 +01:00
|
|
|
enable_rbac: yes
|
2018-05-17 01:08:27 +02:00
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: Assert the AKS instance is well created
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
|
|
|
- output.provisioning_state == 'Succeeded'
|
|
|
|
|
|
|
|
- name: Get AKS fact
|
|
|
|
azure_rm_aks_facts:
|
2019-03-04 10:15:04 +01:00
|
|
|
name: "aks{{ rpfx }}"
|
2018-05-17 01:08:27 +02:00
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
register: fact
|
|
|
|
|
|
|
|
- name: Assert fact returns the created one
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "fact.aks | length == 1"
|
|
|
|
- fact.aks[0].id == output.id
|
|
|
|
|
|
|
|
- name: Create an AKS instance (idempotent)
|
|
|
|
azure_rm_aks:
|
2019-03-04 10:15:04 +01:00
|
|
|
name: "aks{{ rpfx }}"
|
2018-05-17 01:08:27 +02:00
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
location: eastus
|
2019-03-04 10:15:04 +01:00
|
|
|
dns_prefix: "aks{{ rpfx }}"
|
|
|
|
kubernetes_version: "{{ versions.azure_aks_versions[0] }}"
|
2018-05-17 01:08:27 +02:00
|
|
|
service_principal:
|
2019-03-01 03:25:49 +01:00
|
|
|
client_id: "{{ azure_client_id }}"
|
2018-05-17 01:08:27 +02:00
|
|
|
linux_profile:
|
|
|
|
admin_username: azureuser
|
|
|
|
ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
|
|
|
|
agent_pool_profiles:
|
|
|
|
- name: default
|
|
|
|
count: 1
|
|
|
|
vm_size: Standard_DS1_v2
|
2018-10-29 07:36:38 +01:00
|
|
|
enable_rbac: yes
|
2018-05-17 01:08:27 +02:00
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: Assert idempotent
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- not output.changed
|
|
|
|
|
2019-03-04 10:15:04 +01:00
|
|
|
- name: Get available version
|
|
|
|
azure_rm_aks_version:
|
|
|
|
location: eastus
|
|
|
|
version: "{{ versions.azure_aks_versions[0] }}"
|
|
|
|
register: version1
|
|
|
|
|
|
|
|
- name: Upgrade the AKS instance with addon
|
2018-05-17 01:08:27 +02:00
|
|
|
azure_rm_aks:
|
2019-03-04 10:15:04 +01:00
|
|
|
name: "aks{{ rpfx }}"
|
2018-05-17 01:08:27 +02:00
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
location: eastus
|
2019-03-04 10:15:04 +01:00
|
|
|
dns_prefix: "aks{{ rpfx }}"
|
|
|
|
kubernetes_version: "{{ version1.azure_aks_versions[0] }}"
|
2018-05-17 01:08:27 +02:00
|
|
|
service_principal:
|
2019-03-01 03:25:49 +01:00
|
|
|
client_id: "{{ azure_client_id }}"
|
2018-05-17 01:08:27 +02:00
|
|
|
linux_profile:
|
|
|
|
admin_username: azureuser
|
|
|
|
ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
|
|
|
|
agent_pool_profiles:
|
|
|
|
- name: default
|
|
|
|
count: 1
|
|
|
|
vm_size: Standard_DS1_v2
|
2019-03-04 10:15:04 +01:00
|
|
|
addon:
|
|
|
|
http_application_routing: {}
|
|
|
|
network_profile:
|
|
|
|
network_plugin: kubenet
|
|
|
|
enable_rbac: yes
|
2018-05-17 01:08:27 +02:00
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: Assert the AKS instance is upgraded
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
2019-03-04 10:15:04 +01:00
|
|
|
- output.kubernetes_version == version1.azure_aks_versions[0]
|
|
|
|
- output.addon.httpApplicationRouting.enabled == True
|
|
|
|
- output.agent_pool_profiles[0].count == 1
|
|
|
|
- output.network_profile.network_plugin == 'kubenet'
|
2018-05-17 01:08:27 +02:00
|
|
|
|
2019-03-04 10:15:04 +01:00
|
|
|
- name: Upgrade the AKS instance with addon (idempontent)
|
2018-05-17 01:08:27 +02:00
|
|
|
azure_rm_aks:
|
2019-03-04 10:15:04 +01:00
|
|
|
name: "aks{{ rpfx }}"
|
2018-05-17 01:08:27 +02:00
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
location: eastus
|
2019-03-04 10:15:04 +01:00
|
|
|
dns_prefix: "aks{{ rpfx }}"
|
|
|
|
kubernetes_version: "{{ version1.azure_aks_versions[0] }}"
|
2018-05-17 01:08:27 +02:00
|
|
|
service_principal:
|
2019-03-01 03:25:49 +01:00
|
|
|
client_id: "{{ azure_client_id }}"
|
2018-05-17 01:08:27 +02:00
|
|
|
linux_profile:
|
|
|
|
admin_username: azureuser
|
|
|
|
ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
|
|
|
|
agent_pool_profiles:
|
|
|
|
- name: default
|
2019-03-04 10:15:04 +01:00
|
|
|
count: 1
|
2018-05-17 01:08:27 +02:00
|
|
|
vm_size: Standard_DS1_v2
|
2019-03-04 10:15:04 +01:00
|
|
|
addon:
|
|
|
|
http_application_routing: {}
|
|
|
|
network_profile:
|
|
|
|
network_plugin: kubenet
|
|
|
|
enable_rbac: yes
|
2018-05-17 01:08:27 +02:00
|
|
|
register: output
|
|
|
|
|
2019-03-04 10:15:04 +01:00
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- not output.changed
|
|
|
|
|
|
|
|
- name: Get AKS fact
|
|
|
|
azure_rm_aks_facts:
|
|
|
|
name: "aks{{ rpfx }}"
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
show_kubeconfig: user
|
|
|
|
register: fact
|
|
|
|
|
|
|
|
- name: Assert fact returns the created one
|
2018-05-17 01:08:27 +02:00
|
|
|
assert:
|
2019-03-04 10:15:04 +01:00
|
|
|
that:
|
|
|
|
- "fact.aks | length == 1"
|
|
|
|
- fact.aks[0].kube_config == output.kube_config
|
2018-05-17 01:08:27 +02:00
|
|
|
|
|
|
|
- name: Delete the AKS instance
|
|
|
|
azure_rm_aks:
|
2019-03-04 10:15:04 +01:00
|
|
|
name: "aks{{ rpfx }}"
|
2018-05-17 01:08:27 +02:00
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
state: absent
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: Assert the AKS instance is well deleted
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
|
|
|
|
|
|
|
- name: Delete the AKS instance (idempotent)
|
|
|
|
azure_rm_aks:
|
2019-03-04 10:15:04 +01:00
|
|
|
name: "aks{{ rpfx }}"
|
2018-05-17 01:08:27 +02:00
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
state: absent
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: Assert idempotent
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- not output.changed
|
|
|
|
|
|
|
|
- name: Get AKS fact
|
|
|
|
azure_rm_aks_facts:
|
2019-03-04 10:15:04 +01:00
|
|
|
name: "aks{{ rpfx }}"
|
2018-05-17 01:08:27 +02:00
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
register: fact
|
|
|
|
|
|
|
|
- name: Assert fact returns empty
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "fact.aks | length == 0"
|