nautobot-ansible icon indicating copy to clipboard operation
nautobot-ansible copied to clipboard

Adding tags on a record optionally shouldn't remove existing tags

Open chris-tomkins-flexgrid opened this issue 1 month ago • 1 comments

ISSUE TYPE
  • Feature Idea
SOFTWARE VERSIONS
pynautobot

2.2.0

Ansible:

2.16.0

Nautobot:

2.2.4

Collection:

5.2.1

SUMMARY

Adding tags on a record optionally shouldn't remove existing tags

STEPS TO REPRODUCE
- name: Creating prefix records in Nautobot, tagged with record-edited-by-ansible
  when: not temporaryskiprun and upstream_agg_switch is defined
  networktocode.nautobot.prefix:
    api_version: "2.1"
    prefix: "{{wansubnetusuallyslash29}}/29"
    location:
      name: "{{nautobot_site}}"
    namespace: "INTERNET.inet.0"
    state: present
    status: "{{'Active' if not awaitingfirstprovision else 'Reserved'}}"
    tags:
      - "Record edited by Ansible"
    tenant: "{{nautobot_tenant}}"
    token: "{{nautobot_read_write_token}}"
    type: Network
    url: https://{{nautobot_api_ip}}
    validate_certs: false # TODO - sort the certs on Nautobot so this isn't required
    vlan:
      name: "{{inventory_hostname|replace(\"-\", \".\")|lower}}.inner"
      site: "{{hostvars[upstream_agg_switch].nautobot_site}}"
      tenant: "{{nautobot_tenant}}"
EXPECTED RESULTS

I would expect to optionally be able to specify whether tags should be overwritten or additive.

ACTUAL RESULTS

Other useful tags unrelated to this Ansible play were removed:

TASK [nautobot_cpe : Creating prefix records in Nautobot, tagged with record-edited-by-ansible] ************************************
--- before
+++ after
@@ -1,4 +1,2 @@
 tags:
-- 484d9663-6ca2-4625-b54e-6eb896083722
 - f9a4e6f3-c27e-49a1-87e9-a9b92d7ce5c6
-- 2ce879e9-28c1-4056-8308-e4d1b1ef5b77

chris-tomkins-flexgrid avatar May 16 '24 16:05 chris-tomkins-flexgrid