summaryrefslogtreecommitdiffstats
path: root/ansible/deployment_poc/tasks/netbox_tags_post.yml
diff options
context:
space:
mode:
authorGeorg2022-01-05 23:59:13 +0100
committerGeorg2022-01-05 23:59:13 +0100
commit7bb88aaa661dc6756e862562c47368de11657f44 (patch)
tree545d6f1d86c1d42ed04d558450996c54fdca631d /ansible/deployment_poc/tasks/netbox_tags_post.yml
parent0e53f4d766e95205b20951fd252f6118ce05352b (diff)
downloadsystem-7bb88aaa661dc6756e862562c47368de11657f44.tar.gz
system-7bb88aaa661dc6756e862562c47368de11657f44.tar.bz2
system-7bb88aaa661dc6756e862562c47368de11657f44.zip
Init Ansible NetBox DHCP POC deployment
Signed-off-by: Georg <georg@lysergic.dev>
Diffstat (limited to 'ansible/deployment_poc/tasks/netbox_tags_post.yml')
-rw-r--r--ansible/deployment_poc/tasks/netbox_tags_post.yml24
1 files changed, 24 insertions, 0 deletions
diff --git a/ansible/deployment_poc/tasks/netbox_tags_post.yml b/ansible/deployment_poc/tasks/netbox_tags_post.yml
new file mode 100644
index 0000000..9b24ca3
--- /dev/null
+++ b/ansible/deployment_poc/tasks/netbox_tags_post.yml
@@ -0,0 +1,24 @@
+---
+- name: Post-deployment tagging
+ block:
+ - name: Construct body for tagging
+ set_fact:
+ body2: ' {% for tag in tag_exist %}{% if loop.last %}{"slug": "{{ tag }}"}{% else %}{"slug": "{{ tag }}"},{% endif %}{% endfor %}'
+ when: tag_exist is defined
+
+ - name: Set post-deployment tags
+ ansible.builtin.uri:
+ url: "{{ endpoint }}/virtualization/virtual-machines/{{ id }}/"
+ client_cert: "{{ cert }}"
+ client_key: "{{ key }}"
+ method: PATCH
+ return_content: yes
+ headers:
+ Accept: application/json
+ Authorization: "Token {{ token }}"
+ body_format: json
+ body: ' {"tags": [ {{ body2 }}]}'
+ delegate_to: localhost
+ when: body2 is defined
+ no_log: true
+