Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Multiple tags per node

29 views
Skip to first unread message

Iohannes Nerevar

unread,
Sep 2, 2024, 9:00:27 AM9/2/24
to rundeck-discuss
Hello everyone !

I use netbox inventory plugin (netbox.netbox.nb_inventory) to generate my ansible inventory. This inventory is then used by rundeck to generate nodes and deploy various things.
In netbox, I have a virtual machine which has 2 tags. It seems that these 2 tags are correctly reported in the ansible inventory.
The problem is that there is no more than one tag once the node is updated in rundeck.

Any idea?

Thanks

rac...@rundeck.com

unread,
Sep 2, 2024, 10:49:28 AM9/2/24
to rundeck-discuss
Hi,

Did you set the Gather facts to "yes" in your Ansible model source config?

Regards.

Iohannes Nerevar

unread,
Sep 9, 2024, 4:22:52 AM9/9/24
to rundeck-discuss
Hi,

Here's a solution :

netbox_inventory.yml
plugin: netbox.netbox.nb_inventory
api_endpoint: https://@IP
token: @TOKEN
flatten_custom_fields: true
validate_certs: False
config_context: false
flatten_local_context_data: true
query_filters:
  - status: 'active'
device_query_filters:
  - id: -1
  - has_primary_ip: 'true'
vm_query_filters:
  - has_primary_ip: 'true'
compose:
  tags: tags|map(attribute="slug")|join(",")
  status: status.value
  sites: status.value
  nodename: name
  hostname: primary_ip4.address|ansible.utils.ipaddr('address')

Import data :
ansible-inventory -i netbox_inventory.yml --list | jq ._meta.hostvars  > hosts.json

Rundeck Node Source / File :
Format: resourcejson
File Path:/path/to//hosts.json
Require File Exists: Yes

By doing so, Rundeck retrieves all the tags defined in Netbox and these can be used in a job to target different types of nodes.

Regards
Reply all
Reply to author
Forward
0 new messages