network_element - Create, modify or delete network elements

New 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 is seen with a duplicate name, etc 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 also specify the required options and create the element if it doesn’t exist.

Options

parameter required default choices comments
elements
yes
A list of the elements to create, modify or remove
Dictionary object elements
parameter required default choices comments
netlink
no
Create a Static Netlink element
group
no
A group of network elements
network
no
A network element of type network
domain_name
no
Domain name element to be used in rule
host
no
A network element of type host
address_range
no
A network element of type address range
interface_zone
no
A zone tag optionally assigned to an interface
router
no
A router element
ip_list
no
An IP list element containing individual addresses and networks
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_ADDRESS

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_KEY Required if url

smc_api_version
no

Optional API version to connect to. If none is provided, the latest SMC version API will be used based on the Management Center version. Can be set though the environment variable SMC_API_VERSION

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_DOMAIN

smc_extra_args
no
Extra arguments to pass to login constructor. These are generally only used if specifically requested by support personnel.
Dictionary object smc_extra_args
parameter required default choices comments
verify
no True
  • yes
  • no
Is the connection to SMC is HTTPS, you can set this to True, or provide a path to a client certificate to verify the SMC SSL certificate. You can also explicitly set this to False.
smc_logging
no
Optionally enable SMC API logging to a file
Dictionary object smc_logging
parameter required default choices comments
path
yes
Full path to the log file
level
no
Log level as specified by the standard python logging library, in int format. Default setting is logging.DEBUG.
smc_timeout
no

Optional timeout for connections to the SMC. Can be set through environment SMC_TIMEOUT

state
no present
  • present
  • absent

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 dlepage
        - 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
        - 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'}]


Author

  • David LePage (@gabstopper)

Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.