napalm_install_config
This library will take the configuration from a file and load it into a device running any OS supported by napalm. The old configuration will be replaced or merged with the new one.
Parameters
Parameter |
Required |
Default |
Choices |
Description |
archive_file |
False |
N/A |
N/A |
File to store backup of running-configuration from device. Configuration will not be retrieved if not set. |
candidate_file |
False |
N/A |
N/A |
Store a backup of candidate config from device prior to a commit. |
commit_changes |
True |
N/A |
N/A |
If set to True the configuration will be actually merged or replaced. If the set to False, we will not apply the changes, just check and report the diff |
config |
False |
N/A |
N/A |
Configuration to load. Either config or config_file is needed. |
config_file |
False |
N/A |
N/A |
Path to the file to load the configuration from. Either config or config_file is needed. |
dev_os |
False |
N/A |
N/A |
OS of the device |
diff_file |
False |
N/A |
N/A |
A path to the file where we store the "diff" between the running configuration and the new configuration. If not set the diff between configurations will not be saved. |
get_diffs |
False |
N/A |
N/A |
Set to False to not have any diffs generated. Useful if platform does not support commands being used to generate diffs. Note- By default diffs are generated even if the diff_file param is not set. |
hostname |
False |
N/A |
N/A |
IP or FQDN of the device you want to connect to |
optional_args |
False |
N/A |
N/A |
Dictionary of additional arguments passed to underlying driver |
password |
False |
N/A |
N/A |
Password |
provider |
False |
N/A |
N/A |
Dictionary which acts as a collection of arguments used to define the characteristics of how to connect to the device. Connection arguments can be inferred from inventory and CLI arguments or specified in a provider or specified individually. |
replace_config |
False |
N/A |
N/A |
If set to True, the entire configuration on the device will be replaced during the commit. If set to False, we will merge the new config with the existing one. |
timeout |
False |
N/A |
N/A |
Time in seconds to wait for the device to respond |
username |
False |
N/A |
N/A |
Username |
Examples
- assemble:
src: '../compiled/{{ inventory_hostname }}/'
dest: '../compiled/{{ inventory_hostname }}/running.conf'
- name: Install Config and save diff
napalm_install_config:
hostname: '{{ inventory_hostname }}'
username: '{{ user }}'
dev_os: '{{ os }}'
password: '{{ passwd }}'
config_file: '../compiled/{{ inventory_hostname }}/running.conf'
commit_changes: '{{ commit_changes }}'
replace_config: '{{ replace_config }}'
get_diffs: True
diff_file: '../compiled/{{ inventory_hostname }}/diff'
- name: Install Config using Provider
napalm_install_config:
provider: "{{ ios_provider }}"
config_file: '../compiled/{{ inventory_hostname }}/running.conf'
commit_changes: '{{ commit_changes }}'
replace_config: '{{ replace_config }}'
get_diffs: True
diff_file: '../compiled/{{ inventory_hostname }}/diff'
Return
Name |
Description |
Returned |
Type |
Sample |
changed |
whether the config on the device was changed |
always |
bool |
True |
diff |
diff of the change |
always |
dict |
{'prepared': '[edit system] - host-name lab-testing; + host-name lab;'} |