-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_tag.yml
39 lines (33 loc) · 1.47 KB
/
create_tag.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
# ======= How to run w non-root Ansible user:
# boburciu@WX-5CG020BDT2: ~$ cd ~/netbox-ansible-automation
# boburciu@WX-5CG020BDT2:~/netbox-ansible-automation$ ansible-playbook -i ./hosts -v create_tag.yml -e 'tag1_name="contrail" tag1_description="Juniper Contrail SDN backend"'
# boburciu@WX-5CG020BDT2:~/netbox-ansible-automation$ ansible-playbook -i ./hosts -v create_tag.yml -e 'external_vars="../parse_excel_servers/external_vars_CZ00CHASSIS1.yml"'
- name: Create Tag
connection: local
hosts: docker_netbox_19216820023
gather_facts: False
collections:
- netbox.netbox
tasks:
# - include_vars: external_vars.yml
- include_vars: '{{external_vars}}'
- name: Create tags
netbox_tag:
netbox_url: "{{ url_var }}"
netbox_token: "{{ token_var }}"
data:
name: "{{ item.name }}"
description: "{{ item.description }}"
color: "{{ item.color }}"
state: present # Use present or absent for adding/creation or removing/deletion
loop:
- { name: "{{tag_name}}", description: "{{tag_description}}", color: "{{tag_color}}" }
- name: Obtain all tags
# debug:
# msg: "{{ item }}"
debug:
msg: >
"Tag {{ item.value.name }} has description:{{ item.value.description }} "
loop: "{{ query('netbox.netbox.nb_lookup', 'tags',
api_endpoint=url_var,
token=token_var) }}"