-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_tenant.yml
46 lines (42 loc) · 1.63 KB
/
create_tenant.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# ======= How to run standalone:
# boburciu@WX-5CG020BDT2: ~$ cd ~/netbox-ansible-automation
# boburciu@WX-5CG020BDT2:~/netbox-ansible-automation$ ansible-playbook -i ./hosts -v create_tenant.yml -e 'tenant_name="G4R2Huawei" external_vars="../parse_excel_servers/external_vars_CZ00CHASSIS1.yml"'
- name: Create Tenant
connection: local
hosts: docker_netbox_19216820023
gather_facts: False
collections:
- netbox.netbox
tasks:
# - include_vars: external_vars.yml
- include_vars: '{{external_vars}}'
# Create first a tenant group and add the afterwards created tenant to it
- name: Create tenant group with all parameters
netbox_tenant_group:
netbox_url: "{{ url_var }}"
netbox_token: "{{ token_var }}"
data:
name: "{{ tenant_group_name }}"
state: present
- name: Create tenant with all parameters
netbox_tenant:
netbox_url: "{{ url_var }}"
netbox_token: "{{ token_var }}"
data:
name: "{{ tenant_name }}"
tenant_group: "{{ tenant_group_name }}"
description: "{{ tenant_description }}"
state: present
- name: Create tenant and assign tag and comment, if available
netbox_tenant:
netbox_url: "{{ url_var }}"
netbox_token: "{{ token_var }}"
data:
name: "{{ tenant_name }}"
tenant_group: "{{ tenant_group_name }}"
description: "{{ tenant_description }}"
# comments: "{{ tenant_comments }}"
tags:
- "{{ tenant_tag }}"
state: present
when: tenant_tag is defined