Skip to content

Commit

Permalink
Move kube config reconfiguration into aks-addons
Browse files Browse the repository at this point in the history
  • Loading branch information
optionsome committed Jul 20, 2020
1 parent 5a0af76 commit a15af4c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 36 deletions.
7 changes: 7 additions & 0 deletions roles/aks-addons/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,10 @@

when:
- addons_to_remove is defined

- name: "Configure kubectl to use {{aks_name}}"
command: "az aks get-credentials \
--resource-group {{aks_resource_group_name}} \
--name {{aks_name}}"
delegate_to: localhost
ignore_errors: "{{ ansible_check_mode }}"
64 changes: 28 additions & 36 deletions roles/aks-setup/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,35 @@
---
- block:
- name: "Create service principal"
command: "az ad sp create-for-rbac \
-n {{aks_name}} \
--skip-assignment \
--years 100"
delegate_to: localhost
ignore_errors: "{{ ansible_check_mode }}"
register: out

- set_fact:
json: "{{(out.stdout|from_json)}}"
- name: "Create service principal"
command: "az ad sp create-for-rbac \
-n {{aks_name}} \
--skip-assignment \
--years 100"
delegate_to: localhost
ignore_errors: "{{ ansible_check_mode }}"
register: out

- name: "Create {{aks_resource_group_name}}"
command: "az group create \
--name {{aks_resource_group_name}} \
--location {{ az_region }}"
delegate_to: localhost
ignore_errors: "{{ ansible_check_mode }}"
- set_fact:
json: "{{(out.stdout|from_json)}}"

- name: "Create {{aks_name}}"
command: "az aks create \
--resource-group {{aks_resource_group_name}} \
--name {{aks_name}} \
--node-count {{node_count}} \
--node-vm-size {{node_vm_size}} \
--kubernetes-version {{kubernetes_version}} \
--generate-ssh-keys \
--service-principal {{item.appId}} \
--client-secret {{item.password}} \
--no-wait"
delegate_to: localhost
ignore_errors: "{{ ansible_check_mode }}"
with_items:
- { appId: "{{json.appId}}", password: "{{json.password}}" }
- name: "Create {{aks_resource_group_name}}"
command: "az group create \
--name {{aks_resource_group_name}} \
--location {{ az_region }}"
delegate_to: localhost
ignore_errors: "{{ ansible_check_mode }}"

- name: "Configure kubectl to use {{aks_name}}"
command: "az aks get-credentials \
- name: "Create {{aks_name}}"
command: "az aks create \
--resource-group {{aks_resource_group_name}} \
--name {{aks_name}}"
--name {{aks_name}} \
--node-count {{node_count}} \
--node-vm-size {{node_vm_size}} \
--kubernetes-version {{kubernetes_version}} \
--generate-ssh-keys \
--service-principal {{item.appId}} \
--client-secret {{item.password}} \
--no-wait"
delegate_to: localhost
ignore_errors: "{{ ansible_check_mode }}"
with_items:
- { appId: "{{json.appId}}", password: "{{json.password}}" }

0 comments on commit a15af4c

Please sign in to comment.