Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vegas version #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,287 @@
---
- hosts: localhost
connection: local
gather_facts: no

collections:
- vmware.alb

tasks:
- name: Debug
debug:
msg: "{{ avi_credentials }}"
tags:
- debug

- name: Get GSLB list
vmware.alb.avi_api_session:
avi_credentials: "{{ avi_credentials | default(omit) }}"
api_context: "{{ avi_api_context | default(omit) }}"
http_method: get
path: gslbservice
register: gslbserviceResults
ignore_errors: yes

- name: Delete Glsb services - it may fails if not executed in the leader cluster
vmware.alb.avi_api_session:
avi_credentials: "{{ avi_credentials | default(omit) }}"
api_context: "{{ avi_api_context | default(omit) }}"
http_method: "delete"
path: '{{"gslbservice/" + item.uuid }}'
ignore_errors: yes
loop: "{{ gslbserviceResults.obj.results }}"

- name: Get GSLB profile
vmware.alb.avi_api_session:
avi_credentials: "{{ avi_credentials | default(omit) }}"
api_context: "{{ avi_api_context | default(omit) }}"
http_method: get
path: gslbgeodbprofile
register: gslbgeodbprofileResults
ignore_errors: yes

- name: Delete Glsb Geo profile - it may fails if not executed in the leader cluster
vmware.alb.avi_api_session:
avi_credentials: "{{ avi_credentials | default(omit) }}"
api_context: "{{ avi_api_context | default(omit) }}"
http_method: "delete"
path: '{{"gslbgeodbprofile/" + item.uuid }}'
loop: "{{ gslbgeodbprofileResults.obj.results }}"
ignore_errors: yes

- name: Get GSLB config
vmware.alb.avi_api_session:
avi_credentials: "{{ avi_credentials | default(omit) }}"
api_context: "{{ avi_api_context | default(omit) }}"
http_method: get
path: gslb
register: gslbResults
ignore_errors: yes

- name: Delete Glsb config - it may fails if not executed in the leader cluster
vmware.alb.avi_api_session:
avi_credentials: "{{ avi_credentials | default(omit) }}"
api_context: "{{ avi_api_context | default(omit) }}"
http_method: "delete"
path: '{{"gslb/" + item.uuid }}'
loop: "{{ gslbResults.obj.results }}"
ignore_errors: yes

- name: get DNS VS used by system
vmware.alb.avi_api_session:
avi_credentials: "{{ avi_credentials | default(omit) }}"
api_context: "{{ avi_api_context | default(omit) }}"
http_method: get
timeout: 300
path: systemconfiguration
register: systemconfigurationOutput
ignore_errors: yes

- name: Delete DNS VS used by system in systemconfiguration
vmware.alb.avi_api_session:
avi_credentials: "{{ avi_credentials | default(omit) }}"
api_context: "{{ avi_api_context | default(omit) }}"
http_method: patch
timeout: 300
path: systemconfiguration
data: {"delete":{"dns_virtualservice_refs":["{{ item }}"]}}
loop: "{{ systemconfigurationOutput.obj.dns_virtualservice_refs }}"
when: systemconfigurationOutput.obj.dns_virtualservice_refs is defined
ignore_errors: yes

- name: get VS
vmware.alb.avi_api_session:
avi_credentials: "{{ avi_credentials | default(omit) }}"
api_context: "{{ avi_api_context | default(omit) }}"
http_method: get
timeout: 300
path: virtualservice
register: virtualserviceResults
ignore_errors: yes

- name: Delete child VS config
vmware.alb.avi_api_session:
avi_credentials: "{{ avi_credentials | default(omit) }}"
api_context: "{{ avi_api_context | default(omit) }}"
http_method: "delete"
path: '{{"virtualservice/" + item.uuid }}'
loop: "{{ virtualserviceResults.obj.results }}"
loop_control:
label: "{{ item.name }}"
ignore_errors: yes
when:
- item.type != "VS_TYPE_VH_PARENT"

- name: Delete all other VS config
vmware.alb.avi_api_session:
avi_credentials: "{{ avi_credentials | default(omit) }}"
api_context: "{{ avi_api_context | default(omit) }}"
http_method: "delete"
path: '{{"virtualservice/" + item.uuid }}'
loop: "{{ virtualserviceResults.obj.results }}"
loop_control:
label: "{{ item.name }}"
ignore_errors: yes
when:
- item.type == "VS_TYPE_VH_PARENT"

- name: Delete all VS config
vmware.alb.avi_api_session:
avi_credentials: "{{ avi_credentials | default(omit) }}"
api_context: "{{ avi_api_context | default(omit) }}"
http_method: "delete"
path: '{{"virtualservice/" + item.uuid }}'
loop: "{{ virtualserviceResults.obj.results }}"
loop_control:
label: "{{ item.name }}"
ignore_errors: yes

- name: get vsvip
vmware.alb.avi_api_session:
avi_credentials: "{{ avi_credentials | default(omit) }}"
api_context: "{{ avi_api_context | default(omit) }}"
http_method: get
timeout: 300
path: vsvip
register: vsvipResults
ignore_errors: yes

- name: Delete vsvip config
vmware.alb.avi_api_session:
avi_credentials: "{{ avi_credentials | default(omit) }}"
api_context: "{{ avi_api_context | default(omit) }}"
http_method: "delete"
path: '{{"vsvip/" + item.uuid }}'
loop: "{{ vsvipResults.obj.results }}"
loop_control:
label: "{{ item.name }}"
ignore_errors: yes

- name: get http policies
vmware.alb.avi_api_session:
avi_credentials: "{{ avi_credentials | default(omit) }}"
api_context: "{{ avi_api_context | default(omit) }}"
http_method: get
timeout: 300
path: httppolicyset
register: httppolicysetResults
ignore_errors: yes

- name: Delete http policies
vmware.alb.avi_api_session:
avi_credentials: "{{ avi_credentials | default(omit) }}"
api_context: "{{ avi_api_context | default(omit) }}"
http_method: "delete"
path: '{{"httppolicyset/" + item.uuid }}'
loop: "{{ httppolicysetResults.obj.results }}"
loop_control:
label: "{{ item.name }}"
ignore_errors: yes

- name: get l4 policies
vmware.alb.avi_api_session:
avi_credentials: "{{ avi_credentials | default(omit) }}"
api_context: "{{ avi_api_context | default(omit) }}"
http_method: get
timeout: 300
path: l4policyset
register: l4policysetResults
ignore_errors: yes

- name: Delete l4 policies
vmware.alb.avi_api_session:
avi_credentials: "{{ avi_credentials | default(omit) }}"
api_context: "{{ avi_api_context | default(omit) }}"
http_method: "delete"
path: '{{"l4policyset/" + item.uuid }}'
loop: "{{ l4policysetResults.obj.results }}"
loop_control:
label: "{{ item.name }}"
ignore_errors: yes

- name: get vs datascript
vmware.alb.avi_api_session:
avi_credentials: "{{ avi_credentials | default(omit) }}"
api_context: "{{ avi_api_context | default(omit) }}"
http_method: get
timeout: 300
path: vsdatascriptset
register: vsdatascriptsetResults
ignore_errors: yes

- name: Delete vs datascript
vmware.alb.avi_api_session:
avi_credentials: "{{ avi_credentials | default(omit) }}"
api_context: "{{ avi_api_context | default(omit) }}"
http_method: "delete"
path: '{{"vsdatascriptset/" + item.uuid }}'
loop: "{{ vsdatascriptsetResults.obj.results }}"
loop_control:
label: "{{ item.name }}"
ignore_errors: yes

- name: get pool groups
vmware.alb.avi_api_session:
avi_credentials: "{{ avi_credentials | default(omit) }}"
api_context: "{{ avi_api_context | default(omit) }}"
http_method: get
timeout: 300
path: poolgroup
register: poolgroupResults
ignore_errors: yes

- name: Delete pool group config
vmware.alb.avi_api_session:
avi_credentials: "{{ avi_credentials | default(omit) }}"
api_context: "{{ avi_api_context | default(omit) }}"
http_method: "delete"
path: '{{"poolgroup/" + item.uuid }}'
loop: "{{ poolgroupResults.obj.results }}"
loop_control:
label: "{{ item.name }}"
ignore_errors: yes

- name: get pools
vmware.alb.avi_api_session:
avi_credentials: "{{ avi_credentials | default(omit) }}"
api_context: "{{ avi_api_context | default(omit) }}"
http_method: get
timeout: 300
path: pool
register: poolResults
ignore_errors: yes

- name: Delete pool config
vmware.alb.avi_api_session:
avi_credentials: "{{ avi_credentials | default(omit) }}"
api_context: "{{ avi_api_context | default(omit) }}"
http_method: "delete"
path: '{{"pool/" + item.uuid }}'
loop: "{{ poolResults.obj.results }}"
loop_control:
label: "{{ item.name }}"
ignore_errors: yes

- name: Get SE list
vmware.alb.avi_api_session:
avi_credentials: "{{ avi_credentials | default(omit) }}"
api_context: "{{ avi_api_context | default(omit) }}"
http_method: get
path: serviceengine
register: serviceengineResults
ignore_errors: yes

- name: Delete SE
vmware.alb.avi_api_session:
avi_credentials: "{{ avi_credentials | default(omit) }}"
api_context: "{{ avi_api_context | default(omit) }}"
http_method: "delete"
path: '{{"serviceengine/" + item.uuid }}'
loop: "{{ serviceengineResults.obj.results }}"
loop_control:
label: "{{ item.name }}"
ignore_errors: yes

- name: Pausing for 20 seconds
pause:
seconds: 20
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- import_playbook: pbInitController.yml
- import_playbook: pbSystemConfig.yml
- import_playbook: vmw/pbCloudVmw.yml
- import_playbook: vmw/pbVsVmw.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
- hosts: localhost
gather_facts: no

vars_files:
- "vars/params.yml"

collections:
- vmware.alb

tasks:
- name: Set variable avi_credentials
set_fact:
avi_credentials: >
{'api_version': "{{ avi_version }}",
'controller': "{{ controller_ip }}",
'password': "{{ avi_password }}",
'username': "{{ avi_username }}"}
tags:
- creds
when:
- avi_version is defined
- controller_ip is defined
- avi_password is defined
- avi_username is defined

- name: Debug variable avi_credentials
debug:
msg: "{{ avi_credentials }}"
tags:
- debug

- name: Update user admin password
vmware.alb.avi_useraccount:
controller: "{{ avi_credentials.controller }}"
username: "{{ avi_credentials.username }}"
password: "{{ avi_credentials.password }}"
old_password: 58NFaGDJm(PJH0G
api_version: "{{ avi_credentials.api_version }}"
ignore_errors: yes
tags:
- creds

- name: Setting up Random password for users
set_fact:
my_pass: "{{ my_pass | default([]) + [ lookup('password', '/dev/null length=4 chars=ascii_lowercase') + '_' + lookup('password', '/dev/null length=4 chars=ascii_uppercase') + '-' + lookup('password', '/dev/null length=4 chars=digits') | upper ] }}"
loop: "{{ aviUser }}"
loop_control:
label: "Configuring {{ item.name }}"
when:
- aviUser is defined
tags:
- creds
- password
- name: user creation
vmware.alb.avi_user:
avi_credentials: "{{ avi_credentials }}"
name: "{{ item.0.name }}"
obj_username: "{{ item.0.name }}"
obj_password: "{{ item.1 }}"
access: "{{ item.0.access }}"
user_profile_ref: "{{ item.0.user_profile_ref }}"
is_active: "{{ item.0.is_active }}"
is_superuser: "{{ item.0.is_superuser }}"
default_tenant_ref: "{{ item.0.default_tenant_ref }}"
loop: "{{ aviUser|zip(my_pass)|list }}"
loop_control:
label: "Configuring {{ item.0.name }}"
when:
- aviUser is defined
tags:
- creds

- name: Change Avi Credentials - with Ansible user
set_fact:
avi_credentials: >
{'api_version': "{{ avi_version }}",
'controller': "{{ controller_ip }}",
'password': "{{ my_pass.0 }}",
'username': "{{ aviUser.0.name }}"}
tags:
- creds

- name: save json creds
copy:
content: '{"avi_credentials": {{ avi_credentials }} }'
dest: "{{ controller.aviCredsJsonFile | default('~/.creds.json') }}"
tags:
- creds
Loading