Skip to content

Instantly share code, notes, and snippets.

@privateip
Created August 30, 2017 16:57
Show Gist options
  • Save privateip/c5e39666e4d7675cc92e378118ac2e41 to your computer and use it in GitHub Desktop.
Save privateip/c5e39666e4d7675cc92e378118ac2e41 to your computer and use it in GitHub Desktop.
Retrieve partial junos config using junos_command + cli
(ansible) [ansible-junos]$ cat syslog.yaml
---
- hosts: vsrx01
connection: local
gather_facts: no
tasks:
- junos_command:
commands: show configuration system syslog
provider: "{{ cli }}"
(ansible) [ansible-junos]$
(ansible) [ansible-junos]$
(ansible) [ansible-junos]$
(ansible) [ansible-junos]$
(ansible) [ansible-junos]$ play syslog.yaml -vvv
ansible-playbook 2.4.0 (working b35f39479b) last updated 2017/08/30 07:44:29 (GMT -400)
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/sprygada/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /home/sprygada/Workspaces/ansible/lib/ansible
executable location = /home/sprygada/Workspaces/ansible/bin/ansible-playbook
python version = 2.7.13 (default, Jun 26 2017, 10:20:05) [GCC 7.1.1 20170622 (Red Hat 7.1.1-3)]
Using /etc/ansible/ansible.cfg as config file
Parsed /etc/ansible/hosts inventory source with ini plugin
PLAYBOOK: syslog.yaml *****************************************************************************************************************************************************************************
1 plays in syslog.yaml
PLAY [vsrx01] *************************************************************************************************************************************************************************************
META: ran handlers
TASK [junos_command] ******************************************************************************************************************************************************************************
task path: /home/sprygada/Workspaces/playbooks/ansible-junos/syslog.yaml:7
<vsrx01> using connection plugin network_cli
Using module file /home/sprygada/Workspaces/ansible/lib/ansible/modules/network/junos/junos_command.py
<vsrx01> ESTABLISH LOCAL CONNECTION FOR USER: sprygada
<vsrx01> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1504112201.15-11953642853939 `" && echo ansible-tmp-1504112201.15-11953642853939="` echo $HOME/.ansible/tmp/ansible-tmp-1504112201.15-11953642853939 `" ) && sleep 0'
<vsrx01> PUT /tmp/tmpGDG4i_ TO /home/sprygada/.ansible/tmp/ansible-tmp-1504112201.15-11953642853939/junos_command.py
<vsrx01> EXEC /bin/sh -c 'chmod u+x /home/sprygada/.ansible/tmp/ansible-tmp-1504112201.15-11953642853939/ /home/sprygada/.ansible/tmp/ansible-tmp-1504112201.15-11953642853939/junos_command.py && sleep 0'
<vsrx01> EXEC /bin/sh -c 'python /home/sprygada/.ansible/tmp/ansible-tmp-1504112201.15-11953642853939/junos_command.py; rm -rf "/home/sprygada/.ansible/tmp/ansible-tmp-1504112201.15-11953642853939/" > /dev/null 2>&1 && sleep 0'
[WARNING]: arguments wait_for, match, rpcs are not supported when using transport=cli
ok: [vsrx01] => {
"changed": false,
"failed": false,
"invocation": {
"module_args": {
"commands": [
"show configuration system syslog"
],
"display": null,
"host": null,
"interval": 1,
"match": "all",
"password": null,
"port": null,
"provider": {
"host": "vsrx01",
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"port": null,
"ssh_keyfile": null,
"timeout": null,
"transport": "cli",
"username": "ansible"
},
"retries": 10,
"rpcs": null,
"ssh_keyfile": null,
"timeout": null,
"transport": null,
"username": null,
"wait_for": null
}
},
"stdout": [
"user * {\n any emergency;\n}\nfile messages {\n any any;\n authorization info;\n}\nfile interactive-commands {\n interactive-commands any;\n}"
],
"stdout_lines": [
[
"user * {",
" any emergency;",
"}",
"file messages {",
" any any;",
" authorization info;",
"}",
"file interactive-commands {",
" interactive-commands any;",
"}"
]
]
}
META: ran handlers
META: ran handlers
PLAY RECAP ****************************************************************************************************************************************************************************************
vsrx01 : ok=1 changed=0 unreachable=0 failed=0
Playbook run took 0 days, 0 hours, 0 minutes, 5 seconds
(ansible) [ansible-junos]$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment