This repository is a set of Ansible modules and example playbooks for interacting with AXAPI v3 for configuration and monitoring of A10 ACOS-based hardware and virtual appliances. The module code and example playbooks are generated using a combination of Python code and Jinja templates.
We only support Ansible version >=2.9
This code is now being generated using the SDK generator at https://github.com/a10networks/sdkgenerator
a10-acos-axapi is collection of custom ansible modules crated by a10Networks. It can be installed using following ways, it is assumed that ansible is already installed and configured.
ansible-galaxy collection install a10.acos_axapi
Be sure to note the collection path found within the output of the above command. For example:
$ ansible-galaxy collection install a10.acos_axapi
Process install dependency map
Starting collection install process
Installing 'a10.acos_axapi:1.0.0' to '/opt/.ansible/collections/ansible_collections/a10/acos_axapi'
In this example the collection directory path is: /opt/.ansible/collections/ansible_collections/
git clone https://github.com/a10networks/a10-acos-axapi
cd a10-acos-axapi
ansible-galaxy collection build
ansible-galaxy collection install a10-acos_axapi*.tar.gz -p ./collections
-
Copy collection folder we got from tarball inside
- ~/.ansible/collections
- /usr/share/ansible/collections folder
-
Export following environment variables for new session
ANSIBLE_COLLECTIONS_PATHS=<path-to-collections-folders>
-
Add below line in /etc/ansible/ansible.cfg File
collections_paths=<path-to-collection1>:<path-to-collection2>
-
Keep your playbooks to run in relative to collection
|── myplaybook.yml ├── collections/ │ └── ansible_collections/ │ └── a10/ │ └── acos_axapi/<collection structure lives here>
Add below line in the /etc/ansible/ansible.cfg
file
action_plugins = <collection-dir-path>/a10/acos_axapi/plugins/action
-
Copy action plugin into one of the following
- ~/.ansible/plugins
- /usr/share/ansible/plugins folder
-
Export following environment variables for new session
export ANSIBLE_ACTION_PLUGINS=<collection-dir-path>/a10/acos_axapi/plugins/action
- Save this variable in .bashrc File
export ANSIBLE_ACTION_PLUGINS=<collection-dir-path>/a10/acos_axapi/plugins/action
collections:
- a10.acos_axapi
tasks:
- module_name:
- argument
- module_name:
- argument
tasks:
- a10.acos_axapi.module_name:
- argument
- a10.acos_axapi.module_name:
- argument
Sample Inventory file:
[vthunder]
<vthunder host_name/ip_address>
[vthunder:vars]
ansible_username=<username>
ansible_password=<password>
ansible_port=<port>
If you want to use an Inventory file to perform respective configurations through a playbook, you don't need to specify ansible_host
, ansible_username
, ansible_password
and ansible_port
in the playbook.
For example,
- name: <Description of playbook>
connection: local
hosts: <inventory_hostname>
collections:
<a10.acos_axapi>
tasks:
- name: <Description of task>
<module_name>:
<resource_key>: <resource_val>
<another_resource_key>: <another_resource_val>
Use the following command to run playbook using an Inventory file parameters:
ansible-playbook -i <path_to_inventory> <name_of_playbook>
If you don't want to use Inventory file, then specify ansible_host
, ansible_username
, ansible_password
and ansible_port
arguments into playbook itself with hosts as localhost
. And then the configurations will be performed on provided ansible_host
.
For example,
- name: <Description of playbook>
connection: local
hosts: localhost
collections:
<a10.acos_axapi>
tasks:
- name: <Description of task>
<module_name>:
ansible_host: {{ ansible_host }}
ansible_username: {{ ansible_username }}
ansible_password: {{ ansible_password }}
ansible_port: {{ ansible_port }}
<resource_key>: <resource_val>
<another_resource_key>: <another_resource_val>
Use the following command to run the playbook with local arguments:
ansible-playbook <name_of_playbook>
Use the following command to run the playbook:
ansible-playbook -i <path_to_inventory> <name_of_playbook>
Action and module names are formatted based upon their API endpoint. For example, the virtual server endpoint is as follows: /axapi/v3/slb/virtual-server
. As such, the action name is a10_slb_virtual_server
and the module is a10_slb_virtual_server.py
.
**Note that when getting information, changes made to the playbook will not result in a create, update or delete as the state has been put into no-op.
- name: <Description of playbook>
connection: local
hosts: <inventory_hostname>
collections:
<a10.acos_axapi>
tasks:
- name: <Description of task>
<module_name>:
<resource_key>: <resource_val>
<another_resource_key>: <another_resource_val>
- name: <Description of playbook>
connection: local
hosts: <inventory_hostname>
tasks:
- name: <Description of task>
<a10.acos_axapi.module_name>:
<resource_key>: <resource_val>
<another_resource_key>: <another_resource_val>
- name: <Description of playbook> connection: local hosts: <inventory_hostname> tasks: - name: <Description of task> <a10.acos_axapi.module_name>: <resource_key>: <resource_val> <another_resource_key>: <another_resource_val> state: absent
- name: <Description of playbook> connection: local hosts: <inventory_hostname> tasks: - name: <Description of task> <a10.acos_axapi.module_name>: <resource_key>: <resource_val> <another_resource_key>: <another_resource_val> state: noop get_type: single
- name: <Description of playbook> connection: local hosts: <inventory_hostname> tasks: - name: <Description of task> <a10.acos_axapi.module_name>: <resource_key>: <resource_val> <another_resource_key>: <another_resource_val> state: noop get_type: list
- name: <Description of playbook> connection: local hosts: <inventory_hostname> tasks: - name: <Description of task> <a10.acos_axapi.module_name>: <resource_key>: <resource_val> <another_resource_key>: <another_resource_val> state: noop get_type: oper
- name: <Description of playbook> connection: local hosts: <inventory_hostname> tasks: - name: <Description of task> <a10.acos_axapi.module_name>: <resource_key>: <resource_val> <another_resource_key>: <another_resource_val> state: noop get_type: stats
- name: <Description of playbook> connection: local hosts: <inventory_hostname> tasks: - name: <Description of task> <a10.acos_axapi.module_name>: a10_partition: {{ partition_name }} <resource_key>: <resource_val> <another_resource_key>: <another_resource_val>
- name: <Description of playbook> connection: local hosts: <inventory_hostname> tasks: - name: <Description of task> <a10.acos_axapi.module_name>: a10_device_context_id: {{ device_context_id }} <resource_key>: <resource_val> <another_resource_key>: <another_resource_val>
Note: Only available in modules with file_path
argument
- name: <Description of playbook> connection: local hosts: <inventory_hostname> tasks: - name: <Description of task> <a10.acos_axapi.module_name>: file_path: "/path/to/file" <resource_key>: <resource_val> <another_resource_key>: <another_resource_val>
Check mode can be specified in two ways:
- name: <Description of playbook> connection: local hosts: <inventory_hostname> tasks: - name: <Description of task> <a10.acos_axapi.module_name>: <resource_key>: <resource_val> <another_resource_key>: <another_resource_val> check_mode: yes
or
$ ansible-playbook -i <path_to_inventory> <playbook_name>.yml --check-mode
$ ansible-doc -M <collection-dir-path> <module_name>
Please refer : /examples/single_task/admin/adminPassword/README.md
Sample test cases added for the following configurations:
- Bgp
- Check Mode
- Class List
- Default Gateway
- files
- Gslb
- Health
- Network
- Slb
- Slb Template
To test configurations on the acos using ansible playbooks goto test
directory and use the following command:
sh run_test_playbooks.sh
Please see (https://github.com/a10networks/a10-acos-axapi/tree/master/examples) for example playbooks.
For all issues, please send an email to [email protected]