Ansible Master
Ansible Master
Ansible Master
Modules
cli_backup module – Back up device configuration from network devices over
network_cli
cli_command module – Run a cli command on cli-based network devices
cli_config module – Push text based configuration to network devices over network_cli
grpc_config module – Fetch configuration/state data from gRPC enabled target hosts.
grpc_get module – Fetch configuration/state data from gRPC enabled target hosts.
net_get module – Copy a file from a network device to Ansible Controller
net_ping module – Tests reachability using ping from a network device
net_put module – Copy a file from Ansible Controller to a network device
netconf_config module – netconf device configuration
netconf_get module – Fetch configuration/state data from NETCONF enabled network
devices.
netconf_rpc module – Execute operations on NETCONF enabled network devices.
network_resource module – Manage resource modules
restconf_config module – Handles create, update, read and delete of configuration data
on RESTCONF enabled devices.
restconf_get module – Fetch configuration/state data from RESTCONF enabled devices.
telnet module – Executes a low-down and dirty telnet command
Become Plugins
enable become – Switch to elevated permissions on a network device
Cache Plugins
memory cache – RAM backed, non persistent cache.
Cliconf Plugins
default cliconf – General purpose cliconf plugin for new platforms
Connection Plugins
grpc connection – Provides a persistent connection using the gRPC protocol
httpapi connection – Use httpapi to run command on network appliances
libssh connection – Run tasks using libssh for ssh connection
netconf connection – Provides a persistent connection using the netconf protocol
network_cli connection – Use network_cli to run command on network appliances
persistent connection – Use a persistent unix socket for connection
Filter Plugins
comp_type5 filter – The comp_type5 filter plugin.
hash_salt filter – The hash_salt filter plugin.
parse_cli filter – parse_cli filter plugin.
parse_cli_textfsm filter – parse_cli_textfsm filter plugin.
parse_xml filter – The parse_xml filter plugin.
pop_ace filter – Remove ace entries from a acl source of truth.
type5_pw filter – The type5_pw filter plugin.
vlan_expander filter – The vlan_expander filter plugin.
vlan_parser filter – The vlan_parser filter plugin.
Httpapi Plugins
restconf httpapi – HttpApi Plugin for devices supporting Restconf API
Netconf Plugins
default netconf – Use default netconf plugin to run standard netconf commands as per
RFC
Ansible Galaxy
https://galaxy.ansible.com/ui/repo/published/ansible/netcommon/?
extIdCarryOver=true&sc_cid=701f2000001OH7YAAW
ADHOC COMMAND
IOS_FACTS
(venv-ansible) jerin@jerin:/$ ansible all -i devnetsandboxiosxe.cisco.com,192.168.234.135, -c
ansible.netcommon.network_cli -u jerin -k -m cisco.ios.ios_facts -e ansible_network_os=cisco.ios.ios
SSH password:
[WARNING]: ansible-pylibssh not installed, falling back to paramiko
192.168.234.135 | SUCCESS => {
"ansible_facts": {
"ansible_net_api": "cliconf",
"ansible_net_gather_network_resources": [],
"ansible_net_gather_subset": [
"default"
],
"ansible_net_hostname": "R1",
"ansible_net_image": "tftp://255.255.255.255/unknown",
"ansible_net_iostype": "IOS",
"ansible_net_model": "7206VXR",
"ansible_net_operatingmode": "autonomous",
"ansible_net_python_version": "3.10.12",
"ansible_net_serialnum": "4279256517",
"ansible_net_system": "ios",
"ansible_net_version": "15.2(4)M7",
"ansible_network_resources": {}
},
"changed": false
}
devnetsandboxiosxe.cisco.com | SUCCESS => {
"ansible_facts": {
"ansible_net_api": "cliconf",
"ansible_net_gather_network_resources": [],
"ansible_net_gather_subset": [
"default"
],
"ansible_net_hostname": "iosxe",
"ansible_net_image": "bootflash:packages.conf",
"ansible_net_iostype": "IOS-XE",
"ansible_net_model": "C8000V",
"ansible_net_operatingmode": "autonomous",
"ansible_net_python_version": "3.10.12",
"ansible_net_serialnum": "9OBXJHNNU5V",
"ansible_net_system": "ios",
"ansible_net_version": "17.12.02",
"ansible_network_resources": {}
},
"changed": false
Command line
Changes can be made and used in a configuration file which will be searched for in the following order: PRIORITY
ORDER
ANSIBLE_CONFIG (environment variable if set)
ansible.cfg (in the current directory)
~/.ansible.cfg (in the home directory)
/etc/ansible/ansible.cfg
Export ANSIBLE_CONFIG
(venv-ansible) jerin@jerin:~$ export ANSIBLE_CONFIG=/home/jerin/ansible.cfg
(venv-ansible) jerin@jerin:~$ echo $ANSIBLE_CONFIG
/home/jerin/ansible.cfg
Magic variables
https://docs.ansible.com/ansible/latest/reference_appendices/special_variables.html
ansible_config_file
The full path of used Ansible configuration file
Lab_hosts is configured with the local under ansible_connection module
Playbook Variables
Not all strings are valid Ansible variable names. A variable name can only include letters, numbers, and
underscores. Python keywords or playbook keywords are not valid variable names. A variable name
cannot begin with a number.