diff --git a/README.md b/README.md index 773788d..930b5be 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ int his role inlcuding both configuration and fact collection. ## Requirements -* Ansible 2.6 or later -* Ansible Network Engine Role 2.6.0 or later +* Ansible 2.7 or later +* Ansible Network Engine Role 2.7.0 or later ## Functions diff --git a/includes/configure/configure.yaml b/includes/configure/configure.yaml deleted file mode 100644 index 29eb4af..0000000 --- a/includes/configure/configure.yaml +++ /dev/null @@ -1,49 +0,0 @@ ---- -# configure -# -- name: load configuration - block: - - name: enter configuration mode - cli: - command: configure - - - name: load configuration lines - cli: - command: "{{ line.strip() }}" - loop: "{{ iosxr_config_text | to_lines }}" - loop_control: - loop_var: line - - - name: check the config diff before committing - cli: - command: show commit changes diff - register: iosxr_config_diff - - - name: display config diff - debug: - msg: "{{ iosxr_config_diff.stdout.splitlines() }}" - - - name: commit the configuration only if there is difference - cli: - command: commit - when: iosxr_config_diff.stdout.splitlines()|length > 3 - changed_when: true - - - name: abort the configuration due to check mode - cli: - command: abort - when: ansible_check_mode - - - name: end the configuration session - cli: - command: end - when: not ansible_check_mode - - rescue: - - name: abort configuration - cli: - command: abort - - - name: mark the host as failed - fail: - msg: "error loading configuration onto target device" diff --git a/meta/config_manager/load.yaml b/meta/config_manager/load.yaml new file mode 100644 index 0000000..40f6724 --- /dev/null +++ b/meta/config_manager/load.yaml @@ -0,0 +1,14 @@ +--- +argument_spec: + + ansible_network_os: + description: + - Set the name of the Ansible network OS platform. This value should be + set to `iosxr` for this provider. + required: true + + config_manager_text: + description: + - Provide the network device configuration as a single string. The + configuration text will be loaded onto the target network deivce. + type: str diff --git a/meta/load_config_spec.yaml b/meta/load_config_spec.yaml deleted file mode 100644 index 0be98f1..0000000 --- a/meta/load_config_spec.yaml +++ /dev/null @@ -1,29 +0,0 @@ ---- -argument_spec: - ansible_network_os: - description: - - Set the name of Ansible network os platform. This value should be - set to `iosxr` for this provider role. - required: true - - iosxr_config_text: - description: - - Provide the network device configuration as a single string. The - configuration text will be loaded onto the target network device. - type: str - aliases: - - config_text - - iosxr_config_file: - description: - - Provide relative or absolute path to the configuration file to be - loaded onto the target network device. - type: str - aliases: - - config_file - -mutually_exclusive: - - ['iosxr_config_text', 'iosxr_config_file'] - -required_one_of: - - ['iosxr_config_text', 'iosxr_config_file'] diff --git a/meta/main.yml b/meta/main.yml index 1d6c345..c8cf852 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -7,7 +7,7 @@ galaxy_info: license: GPLv3 min_ansible_version: 2.7 - min_ansible_network_engine_version: 2.6.2 + min_ansible_network_engine_version: 2.7.0 # If this a Container Enabled role, provide the minimum Ansible Container version. # min_ansible_container_version: diff --git a/tasks/config_manager/load.yaml b/tasks/config_manager/load.yaml index 47b22c2..6ee4304 100644 --- a/tasks/config_manager/load.yaml +++ b/tasks/config_manager/load.yaml @@ -4,15 +4,13 @@ - name: initialize function include_tasks: includes/init.yaml -- name: validate task arguments - validate_role_spec: - spec: load_config_spec.yaml +- name: validate config_manager_text is defined + fail: + msg: "missing required arg: config_manager_text" + when: config_manager_text is undefined -- name: lookup config file - set_fact: - iosxr_config_text: "{{ lookup('config_template', iosxr_config_file) | join('\n') }}" - when: iosxr_config_file != '' - -- name: Include configure task - include_tasks: includes/configure/configure.yaml - when: not ansible_check_mode and not iosxr_config_replace +- name: load configuration into device + cli_config: + config: "{{ iosxr_config_text }}" + vars: + iosxr_config_text: "{{ config_manager_text }}"