-
Notifications
You must be signed in to change notification settings - Fork 1
/
swipam.ini
159 lines (156 loc) · 6.6 KB
/
swipam.ini
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# SolarWinds IPAM as an Ansible dynamic inventory
# <https://github.com/alexkross/swipam-script>
# Designed for huge network topologies.
# See also <https://gist.github.com/alexkross/7f80accff12649b940fc9779813b9b91>
#
# Inspired by and/or based on:
# - https://github.com/ansible/ansible/blob/devel/contrib/inventory/foreman.py
# That is somewhat based on cobbler inventory
# - https://github.com/ansible/ansible/blob/devel/contrib/inventory/cloudforms.py
# - https://gist.github.com/alexkross/7f80accff12649b940fc9779813b9b91
# - https://github.com/cbabs/solarwinds-ansible-inv and forks
#
# This script is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with it. If not, see <http://www.gnu.org/licenses/>.
#
# Search list:
#
## * `/etc/ansible/<script>.ini`
# * Current directory of your inventory script.
# * `<SCRIPT>_INI_PATH` environment variable.
#
# ToDo (uncertainly):
## ## Automatic Ansible groups
##
## The inventory will provide a set of groups, by default prefixed by
## '<script>_'. If you want to customize this prefix, change the
## group_prefix option in /etc/ansible/<script>.ini. The rest of this
## guide will assume the default prefix of '<script>'
##
## The hostgroup, location, organization, content view, and lifecycle
## environment of each host are created as Ansible groups with a
## <script>_<grouptype> prefix, all lowercase and problematic parameters
## removed. So e.g. the <script> hostgroup
##
## myapp / webtier / datacenter1
##
## would turn into the Ansible group:
##
## <script>_hostgroup_myapp_webtier_datacenter1
##
## If the parameter want_hostcollections is set to true, the
## collections each host is in are created as Ansible groups with a
## <script>_hostcollection prefix, all lowercase and problematic
## parameters removed. So e.g. the SolarWinds IPAM host collection
##
## Patch Window Thursday
##
## would turn into the Ansible group:
##
## <script>_hostcollection_patchwindowthursday
##
## If the parameter host_filters is set, it will be used as the
## "search" parameter for the /api/v2/hosts call. This can be used to
## restrict the list of returned host, as shown below.
##
## Furthermore Ansible groups can be created on the fly using the
## *group_patterns* variable in *<script>.ini* so that you can build up
## hierarchies using parameters on the hostgroup and host variables.
##
## Let's assume you have a host that is built using this nested hostgroup:
##
## myapp / webtier / datacenter1
##
## and each of the hostgroups defines a parameters respectively:
##
## myapp: app_param = myapp
## webtier: tier_param = webtier
## datacenter1: dc_param = datacenter1
##
## The host is also in a subnet called "mysubnet" and provisioned via an image
## then *group_patterns* like:
##
## [ansible]
## group_patterns = ["{app_param}-{tier_param}-{dc_param}",
## "{app_param}-{tier_param}",
## "{app_param}",
## "{subnet_name}-{provision_method}"]
##
## would put the host into the additional Ansible groups:
##
## - myapp-webtier-datacenter1
## - myapp-webtier
## - myapp
## - mysubnet-image
##
## by recursively resolving the hostgroups, getting the parameter keys
## and values and doing a Python *string.format()* like replacement on
## it.
##
[swipam]
host = <SWIS-host.fqdn>
user = <user>
password = <passwd>
# Make a backup raw file that is a zip archive having '.raw.zip' suffix next to cache file.
save_raw = True
##ssl_verify = False
[ansible]
sncols = ['Address', 'CIDR', 'Comments', 'DisplayName', 'GroupTypeText', 'LastDiscovery', 'Location', 'ParentId', 'Status', 'StatusName', 'StatusRanking', 'SubnetId', 'Uri', 'UsedCount', 'VLAN']
hstcols = ['IpNodeId', 'IPAddress', 'IPAddressN', 'Alias', 'MAC', 'DnsBackward', 'DhcpClientName', 'SysName', 'Description', 'Contact', 'Location', 'Vendor', 'MachineType', 'Comments', 'Status', 'AllocPolicy', 'Uri']
internal = ['DisplayName', 'ParentId', 'Uri']
exclude = ['Discovered Subnets', 'Imported Subnet']
grvars = ['Comments']
# NOTE: next text vars may be either None or '':
snvars = ['Comments', 'VLAN', 'Location']
hstvars = ['IPAddress', 'Alias', 'DnsBackward', 'DhcpClientName', 'SysName', 'Description', 'Contact', 'Location', 'Vendor', 'MachineType', 'Comments']
# Bacause 'DnsBackward' is awkward:
hstvarmap = {'DnsBackward': 'HostName'}
#include_root_net = False
#include_nets = ['172.128.0.0/14', '192.168.0.0/24']
include_nets = ['192.168.0.0/24']
#exclude_nets = ['172.160.129.0/24', '172.161.121.0/24', '172.162.0.0/16']
# ToDo:
## Retrieve only hosts from the organization "Web Engineering".
## host_filters = organization="Web Engineering"
#
## Retrieve only hosts from the organization "Web Engineering" that are
## also in the host collection "Apache Servers".
## host_filters = organization="Web Engineering" and host_collection="Apache Servers"
#
#group_prefix = swipam_
#
## Whether to fetch properties from SolarWinds IPAM and store them on the host
#want_props = True
#
## Whether to create Ansible groups for host collections.
## Disabled by default to not break the script for stand-alone SolarWinds IPAM.
#want_hostcollections = False
#
## Whether to interpret global parameters value as JSON (if possible, else take it as it is).
## This allows you to define lists and dictionaries (and more complicated structures)
## variables by entering them as JSON string in SolarWinds IPAM parameters.
## Disabled by default as the change would else not be backward compatible.
#rich_params = False
#
## Whether to populate the ansible_ssh_host variable to explicitly specify the connection target.
## If the swipam 'ip' fact exists then the ansible_ssh_host varibale is populated
## to permit connections where DNS resolution fails.
#want_ansible_ssh_host = False
[cache]
## Optinally, for better security put to a directory with appropriate minimal permissions.
#swipam_cache = ~/.ansible/swipam-cache.json
## Unconditional local cache made with --export --output options. Note: other inventory are still processed.
#local_cache = hosts.json
#max_age = 60 ToDo here and below
## Whether to scan SolarWinds IPAM to add recently created hosts in inventory cache.
#scan_new_hosts = True