network_element - Create, modify or delete network elements¶
Added in version 2.5.
Synopsis¶
Each element type currently supported in this module is documented in the example playbook. Each network element type will have a minimum number of arguments that is required to create the element if it does not exist. Network elements supported by this module have their create constructors documented at http://smc-python.readthedocs.io/en/latest/pages/reference.html#elements. This module uses a ‘update or create’ logic, therefore it is not possible to create the same element twice. If the element exists and the attributes provided are different, the element will be updated before returned. It also means this module can be run multiple times with only slight modifications to the playbook. This is useful when an error, such as a duplicate name, is seen and you must re-adjust the playbook and re-run. For groups, you can reference a member by name, which will require it to exist, or you can specify the required options and create the element if it does not exist.
Requirements (on host that executes module)¶
smc-python
Options¶
| parameter | required | default | choices | comments | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| elements |
yes |
A list of the elements to create, modify or remove
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ignore_err_if_not_found |
no | True |
When deleting elements, whether to ignore an error if the element is not found. This is only used when state=absent. |
|||||||||||||||||||||||||||||||||||||||||||||||||||
| smc_address |
no |
FQDN with port of SMC. The default value is the environment variable |
||||||||||||||||||||||||||||||||||||||||||||||||||||
| smc_alt_filepath |
no |
Provide an alternate path location to read the credentials from. File is expected to be stored in ~.smcrc. If provided, url and api_key settings are not required and will be ignored. |
||||||||||||||||||||||||||||||||||||||||||||||||||||
| smc_api_key |
no |
API key for api client. The default value is the environment variable |
||||||||||||||||||||||||||||||||||||||||||||||||||||
| smc_api_version |
no |
Optional API version to connect to. If none is provided, the latests LTS SMC API version will be used based on the Management Center version. Can be set though the environment variable |
||||||||||||||||||||||||||||||||||||||||||||||||||||
| smc_domain |
no |
Optional domain to log in to. If no domain is provided, 'Shared Domain' is used. Can be set throuh the environment variable |
||||||||||||||||||||||||||||||||||||||||||||||||||||
| smc_extra_args |
no |
Extra arguments to pass to login constructor. These are generally only used if specifically requested by support personnel.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| smc_logging |
no |
Optionally enable SMC API logging to a file
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| smc_timeout |
no |
Optional timeout for connections to the SMC. Can be set through environment |
||||||||||||||||||||||||||||||||||||||||||||||||||||
| state |
no | present |
|
Create or delete flag |
||||||||||||||||||||||||||||||||||||||||||||||||||
Examples¶
- name: Create a network element
hosts: localhost
gather_facts: no
tasks:
- name: Example network element creation
register: result
network_element:
smc_logging:
level: 10
path: ansible-smc.log
elements:
- host:
name: hostb
address: 1.1.1.1
ipv6_address: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
secondary:
- 1.1.1.2
- 1.1.1.3
- network:
name: networka
ipv4_network: 3.3.3.0/24
ipv6_network: fc00::/7
comment: created by example
- address_range:
name: myrange
ip_range: 1.1.1.1-1.1.1.10
- interface_zone:
name: myzone
- domain_name:
name: mydomain.com
comment: foo
- router:
name: myrouter
address: 172.18.1.254
secondary:
- 172.18.1.253
ipv6_address: 2003:dead:beef:4dad:23:46:bb:101
- ip_list:
name: myiplist
comment: testlist
iplist:
- 1.1.1.1
- 1.1.1.2
- 1.1.1.3
- 1.1.1.4
- group:
name: foogroup
#remove_members: true
#append_lists: true
members:
host:
- hosta
- hostb
network:
- networka
engine:
- myfw
- myfw2
- group:
name: emptyregulargrp
members:
- router:
name: myrouter2
address: 13.13.13.13
- network:
name: mynetwork2
ipv4_network: 13.13.13.0/24
- netlink:
name: mynetlink2
gateway:
name: myrouter2
type: router
network:
- mynetwork2
domain_server_address:
- 8.8.8.8
- 8.8.7.7
probe_address:
- 10.10.10.1
comment: added by ansible
- name: Delete network elements. Use a list of elements by name
network_element:
smc_logging:
level: 10
path: ansible-smc.log
state: absent
elements:
- group:
- mygroup
- newgroupa
- host:
- hosta
- hostb
- network:
- networka
- address_range:
- myrange
- interface_zone:
- myzone
- domain_name:
- mydomain.com
- router:
- myrouter
- ip_list:
- myiplist
Return Values¶
Common return values are documented Return Values, the following are the fields unique to this module:
| name | description | returned | type | sample |
|---|---|---|---|---|
| state |
Current state of elements
|
always | list | [{'action': 'created', 'type': 'tcp_service', 'name': 'myservice'}, {'type': 'tcp_service', 'name': 'newservice80'}, {'action': 'created', 'type': 'udp_service', 'name': 'myudp'}, {'type': 'udp_service', 'name': 'udp2000'}, {'action': 'created', 'type': 'ip_service', 'name': 'new service'}] |
Status¶
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.