From 7a597545547ed147e69df508633cc9000b65e5a3 Mon Sep 17 00:00:00 2001 From: Sumit Jaiswal Date: Tue, 5 Feb 2019 15:16:20 +0530 Subject: [PATCH 1/6] cli_config changes Signed-off-by: Sumit Jaiswal --- includes/configure/configure.yaml | 49 ------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 includes/configure/configure.yaml 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" From e40ce532c192cdb60c3427b4cdd03f1dcffd1000 Mon Sep 17 00:00:00 2001 From: Sumit Jaiswal Date: Tue, 5 Feb 2019 15:16:32 +0530 Subject: [PATCH 2/6] cli_config changes Signed-off-by: Sumit Jaiswal --- meta/config_manager/load.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 meta/config_manager/load.yaml 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 From 40c20bc16e6f0e52639960408b9e9533a399a1c0 Mon Sep 17 00:00:00 2001 From: Sumit Jaiswal Date: Tue, 5 Feb 2019 15:16:43 +0530 Subject: [PATCH 3/6] cli_config changes Signed-off-by: Sumit Jaiswal --- meta/load_config_spec.yaml | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 meta/load_config_spec.yaml 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'] From f254474808c8a7516af78b28b365dafc152887bc Mon Sep 17 00:00:00 2001 From: Sumit Jaiswal Date: Tue, 5 Feb 2019 15:16:56 +0530 Subject: [PATCH 4/6] cli_config changes Signed-off-by: Sumit Jaiswal --- tasks/config_manager/load.yaml | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) 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 }}" From 0d231c4daba1724566c8450a9ba551ec36560166 Mon Sep 17 00:00:00 2001 From: Sumit Jaiswal Date: Tue, 5 Feb 2019 15:25:36 +0530 Subject: [PATCH 5/6] cli_config changes Signed-off-by: Sumit Jaiswal --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From 4a69044084b1ee09ccbf2182e59f311c98cd375d Mon Sep 17 00:00:00 2001 From: Sumit Jaiswal Date: Tue, 5 Feb 2019 15:25:56 +0530 Subject: [PATCH 6/6] cli_config changes Signed-off-by: Sumit Jaiswal --- meta/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: