forked from cuxtud/morpheus-ansible2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reserve_vlan.yml
27 lines (24 loc) · 1.08 KB
/
reserve_vlan.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
---
- name: Get the next unused VLAN, run the tasks for aci rest api and then update the db with the values as used.
hosts: all
gather_facts: yes
become: yes
become_user: root
become_method: sudo
tasks:
- name: Get the next available VLAN
shell: /bin/mysql -h 10.30.20.173 -umorpheus -p"{{ lookup('cypher','secret=secret/renmysqlpass') }}" -B -e "use vlan_capture; select vlan from vlan_capture where status like 'unused' limit 1;"
register: free_vlan
- set_fact:
free_vlan={{ free_vlan.stdout[5:] }}
- debug: var=free_vlan
run_once: true
#
#
# All the ACI tasks here
#
# Update the DB to mark the vlan as used.
- name: Mark the vlan as used.
shell: /bin/mysql -h 10.30.20.173 -umorpheus -p"{{ lookup('cypher','secret=secret/renmysqlpass') }}" -B -e "use vlan_capture; UPDATE vlan_capture set status=\""used"\", anp=\""{{ morpheus['customOptions']['fanpname'] }}"\", epg=\""{{ morpheus['customOptions']['fepgname'] }}"\", app_type=\""{{ morpheus['customOptions']['fapptype'] }}"\" where vlan LIKE "{{ free_vlan }}";"
args:
executable: /bin/bash