|
75 | 75 | """
|
76 | 76 |
|
77 | 77 | EXAMPLES = r"""
|
78 |
| -- name: "Test NetBox custom_link module" |
| 78 | +- name: "Test NetBox export_templates module" |
79 | 79 | connection: local
|
80 | 80 | hosts: localhost
|
81 | 81 | tasks:
|
82 |
| - - name: Create a custom link on device |
| 82 | + - name: "Ensure export template for /etc/hosts entries exists" |
83 | 83 | netbox.netbox.netbox_export_template:
|
84 | 84 | netbox_url: http://netbox.local
|
85 | 85 | netbox_token: thisIsMyToken
|
86 | 86 | data:
|
87 |
| - content_type: "dcim.device" |
88 |
| - name: Custom Link |
89 |
| - link_text: "Open Web Management" |
90 |
| - link_url: !unsafe https://{{ obj.name }}.domain.local |
| 87 | + content_types: ["dcim.device", "virtualization.virtualmachine"] |
| 88 | + name: /etc/hosts |
| 89 | + description: "Generate entries for /etc/hosts" |
| 90 | + as_attachment: true |
| 91 | + template_code: !unsafe | |
| 92 | + {% for vm in queryset -%} |
| 93 | + {%- if vm.primary_ip4 and vm.primary_ip6 %} |
| 94 | + {{ vm.primary_ip4.address.ip }} {{ vm.primary_ip6.address.ip }} {{ vm }} |
| 95 | + {%- elif vm.primary_ip4 %} |
| 96 | + {{ vm.primary_ip4.address.ip }} {{ vm }} |
| 97 | + {%- elif vm.primary_ip6 %} |
| 98 | + {{ vm.primary_ip6.address.ip }} {{ vm }} |
| 99 | + {%- endif -%} |
| 100 | + {%- endfor %} |
91 | 101 |
|
92 |
| - - name: Delete the custom link |
| 102 | + - name: Delete the export template |
93 | 103 | netbox.netbox.netbox_export_template:
|
94 | 104 | netbox_url: http://netbox.local
|
95 | 105 | netbox_token: thisIsMyToken
|
96 | 106 | data:
|
97 |
| - content_type: "dcim.device" |
98 |
| - name: Custom Link |
99 |
| - link_text: "Open Web Management" |
100 |
| - link_url: !unsafe https://{{ obj.name }}.domain.local |
| 107 | + content_type: "dcim.device" |
| 108 | + name: /etc/hosts |
101 | 109 | state: absent
|
102 | 110 | """
|
103 | 111 |
|
|
0 commit comments