-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from napalm-automation/command_line_args
Action plugin for support of command-line args
- Loading branch information
Showing
31 changed files
with
174 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
napalm_ansible | ||
napalm_ansible/modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from __future__ import (absolute_import, division, print_function) | ||
__metaclass__ = type | ||
|
||
from ansible.plugins.action.normal import ActionModule as _ActionModule | ||
|
||
|
||
class ActionModule(_ActionModule): | ||
def run(self, tmp=None, task_vars=None): | ||
pc = self._play_context | ||
|
||
if hasattr(pc, "connection_user"): # new in ansible 2.3 | ||
# populate provider values with context values if not set | ||
provider = self._task.args.get('provider', {}) | ||
|
||
provider['hostname'] = provider.get('hostname', provider.get('host', pc.remote_addr)) | ||
provider['username'] = provider.get('username', pc.connection_user) | ||
provider['password'] = provider.get('password', pc.password) | ||
# Timeout can't be passed via command-line as Ansible defaults to a 10 second timeout | ||
provider['timeout'] = provider.get('timeout', 60) | ||
|
||
self._task.args['provider'] = provider | ||
|
||
result = super(ActionModule, self).run(tmp, task_vars) | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
napalm.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
napalm.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
napalm.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
napalm.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
napalm.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
[defaults] | ||
library = ../library/ | ||
library = ../napalm_ansible/modules | ||
action_plugins = ../napalm_ansible/plugins/action | ||
|
||
retry_files_enabled = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
- name: Get facts | ||
hosts: all | ||
connection: local # code is run locally | ||
gather_facts: no # don't gather facts | ||
tasks: | ||
- block: | ||
- name: get facts from device | ||
napalm_get_facts: # NAPALM plugin | ||
dev_os: "{{ os }}" | ||
optional_args: | ||
path: "{{ playbook_dir }}/mocked" | ||
profile: "{{ profile }}" | ||
filter: ['facts'] | ||
register: napalm_facts # store information here | ||
rescue: | ||
# This is expected to fail in ansible < 2.3 | ||
- assert: | ||
that: "{{ ansible_version.full | version_compare('2.3', 'lt') }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
- name: Get facts | ||
hosts: all | ||
connection: local # code is run locally | ||
gather_facts: no # don't gather facts | ||
tasks: | ||
- block: | ||
- name: get facts from device | ||
napalm_get_facts: # NAPALM plugin | ||
dev_os: "{{ os }}" | ||
optional_args: | ||
path: "{{ playbook_dir }}/mocked" | ||
profile: "{{ profile }}" | ||
filter: ['facts'] | ||
register: napalm_facts # store information here | ||
rescue: | ||
# This is expected to fail in ansible < 2.3 | ||
- assert: | ||
that: "{{ ansible_version.full | version_compare('2.3', 'lt') }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
- name: Get facts | ||
hosts: all | ||
connection: local # code is run locally | ||
gather_facts: no # don't gather facts | ||
tasks: | ||
- block: | ||
- name: get facts from device | ||
napalm_get_facts: # NAPALM plugin | ||
hostname: "{{ ansible_host }}" | ||
username: "vagrant" | ||
password: "vagrant" | ||
dev_os: "{{ os }}" | ||
optional_args: | ||
path: "{{ playbook_dir }}/mocked" | ||
profile: "{{ profile }}" | ||
filter: ['facts'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
- name: Get facts | ||
hosts: all | ||
connection: local # code is run locally | ||
gather_facts: no # don't gather facts | ||
tasks: | ||
- block: | ||
- name: get facts from device | ||
napalm_get_facts: # NAPALM plugin | ||
dev_os: "{{ os }}" | ||
optional_args: | ||
path: "{{ playbook_dir }}/mocked" | ||
profile: "{{ profile }}" | ||
filter: ['facts'] | ||
register: napalm_facts # store information here | ||
rescue: | ||
- assert: | ||
that: "napalm_facts.failed == True" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[all] | ||
dummy os=mock profile=[eos] password=vagrant | ||
|
||
[all:vars] | ||
ansible_python_interpreter="/usr/bin/env python" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"fqdn": "localhost", | ||
"hostname": "localhost", | ||
"interface_list": [ | ||
"Ethernet1", | ||
"Ethernet2", | ||
"Ethernet3", | ||
"Ethernet4", | ||
"Management1" | ||
], | ||
"model": "vEOS", | ||
"os_version": "4.15.5M-3054042.4155M", | ||
"serial_number": "", | ||
"uptime": "...", | ||
"vendor": "Arista" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters