Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "msg": "missing required arg: config_manager_text" #88

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#
ios_config_rollback_enabled: true
ios_config_use_terminal: true
ios_config_remove_temp_files: "{{ remove_temp_files | default(True) }}"
ios_config_replace: "{{ config_manager_replace | default(False) }}"

ios_config_source:
running: show running-config
Expand Down
87 changes: 9 additions & 78 deletions docs/config_manager/load.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Below is an example of calling the `config_manager/load` function from the playb
roles:
- name ansible_network.cisco_ios
function: config_manager/load
config_file: files/ios.cfg
config_manager_text: "{{ lookup('file', 'ios.cfg') }}"
```

The above playbook will load the specified configuration file onto each device
Expand All @@ -34,84 +34,29 @@ in the `cisco_ios` host group.
The `config_manager/load` function also supports replacing the current active
configuration with the configuration file located on the Ansible controller.
In order to replace the device's active configuration, set the value of the
`config_replace` setting to `True`.
`config_manager_replace` setting to `True`.

```
- hosts: cisco_ios

roles:
- name ansible_network.cisco_ios
function: config_manager/load
config_file: files/ios.cfg
replace: yes
config_manager_text: "{{ lookup('file', 'ios.cfg') }}"
config_manager_replace: yes
```

## How to load configuration text
The `config_manager/load` function also supports passing the configuration text
directly into the task list for loading onto the target device instead of
having to provide a file name.

In order to pass the configuration as a text string, use the `config_text`
argument instead such as below.

```
- hosts: cisco_ios

roles:
- name ansible_network.cisco_ios
function: config_manager/load
config_text: "{{ lookup('file', 'ios01.cfg') }}"
replace: yes
```



## Implement using tasks
The `config_manager/load` function can also be implemented in the `tasks` for execution
during the play run using either the `include_role` or `import_role` modules as
shown below.

```
- hosts: cisco_ios

tasks:
- name: load configuration onto ios device
include_role:
name: ansible_network.cisco_ios
tasks_from: config_manager/load
vars:
config_file: files/ios.cfg
replace: yes
```

## Arguments

### ios_config_file

Specifies the relative or absolute path to the IOS configuration file to load
into the target the device. The contents of the file should be IOS
configuration statements. This argument is mutually exclusive with
`config_text`.

The defautl value is `None`

#### Aliases

* config_file

### ios_config_text

Specifies the configuration text to load into the remote device. The text
should be provided as a single configuration string with line breaks between
lines. This argument is mutually exclusive with the `config_file` argument.
### config_manager_text

The default value is `None`
This value accepts the text form of the configuration to be loaded on to the remote device.
The configuration file should be the native set of commands used to configure the remote device.

#### Aliases
The default value is `null`

* config_text

### ios_config_replace
### config_manager_replace

Specifies whether or not the source configuration should replace the current
active configuration on the target IOS device. When this value is set to
Expand All @@ -121,10 +66,6 @@ active configuration

The default value is `False`

#### Aliases

* replace

### ios_config_remove_temp_files

Configures the function to remove or not remove the temp files created when
Expand All @@ -134,10 +75,6 @@ accepts a boolean value.

The default value is `True`

##### Aliases

* remove_temp_files

### ios_config_rollback_enabled

Configures whether or not automatic rollback is enabled during the execution of
Expand All @@ -147,9 +84,3 @@ the rollback operation is not performed automatically.

The default value is `True`

#### Aliases

* rollback_enabled

## Notes
None
2 changes: 1 addition & 1 deletion includes/configure/replace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
- name: remove temporary files from target device
cli:
command: "delete /force flash:/{{ ios_config_temp_file }}"
when: ios_config_temp_file in ios_dir_listing.stdout
when: ios_config_temp_file in ios_dir_listing.stdout and ios_config_remove_temp_files

- name: enable the ios scp server
cli:
Expand Down
6 changes: 3 additions & 3 deletions tasks/config_manager/load.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@
block:
- name: replace current active configuration
include_tasks: "{{ role_path }}/includes/configure/replace.yaml"
when: config_manager_replace
when: ios_config_replace
vars:
ios_config_text: "{{ config_manager_text }}"

- name: merge with current active configuration
include_tasks: "{{ role_path }}/includes/configure/merge.yaml"
when: not config_manager_replace and not ios_config_use_terminal
when: not ios_config_replace and not ios_config_use_terminal
vars:
ios_config_text: "{{ config_manager_text }}"

- name: load configuration using configure terminal
include_tasks: "{{ role_path }}/includes/configure/terminal.yaml"
when: not config_manager_replace and ios_config_use_terminal
when: not ios_config_replace and ios_config_use_terminal
vars:
ios_config_text: "{{ config_manager_text }}"

Expand Down