-
Notifications
You must be signed in to change notification settings - Fork 57
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 #473 from netscaler/sshconnection
Migration of sshConnection module for netscaler adc
- Loading branch information
Showing
13 changed files
with
605 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
- name: Ansible ssh playbook | ||
hosts: demo_netscalers | ||
connection: netscaler.adc.ssh_netscaler_adc | ||
remote_user: nsroot | ||
gather_facts: false | ||
|
||
vars: | ||
ansible_python_interpreter: /var/python/bin/python | ||
|
||
tasks: | ||
- name: Calling shell module | ||
register: echo_result | ||
changed_when: false | ||
ansible.builtin.command: "echo hello" | ||
|
||
- name: Show command output | ||
ansible.builtin.debug: | ||
msg: "{{ echo_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,7 @@ | ||
[demo_netscaler1] | ||
demo_netscalers | ||
|
||
[demo_netscaler1:vars] | ||
ansible_host= <nsip> | ||
remote_user= <username> | ||
nitro_pass= <password> |
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,34 @@ | ||
--- | ||
- name: Ansible ssh playbook | ||
hosts: demo_netscalers | ||
connection: netscaler.adc.ssh_netscaler_adc | ||
remote_user: nsroot | ||
gather_facts: false | ||
|
||
vars: | ||
ansible_python_interpreter: /var/python/bin/python | ||
|
||
tasks: | ||
- name: Calling shell module | ||
ansible.builtin.command: "echo hello" | ||
changed_when: false | ||
register: echo_result | ||
|
||
- name: Show command output | ||
ansible.builtin.debug: | ||
msg: "{{ echo_result }}" | ||
|
||
- name: Ansible ssh playbook | ||
hosts: demo_netscalers | ||
gather_facts: false | ||
tasks: | ||
- name: Setup server | ||
delegate_to: localhost | ||
netscaler.adc.server: | ||
nsip: "{{ ansible_host }}" | ||
nitro_user: "{{ remote_user }}" | ||
nitro_pass: "{{ nitro_pass }}" | ||
validate_certs: false | ||
|
||
name: test-server-1 | ||
ipaddress: 192.168.2.2 |
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,25 @@ | ||
--- | ||
- name: Run nscli command | ||
hosts: demo_netscalers | ||
remote_user: nsroot | ||
connection: netscaler.adc.ssh_netscaler_adc | ||
gather_facts: false | ||
vars: | ||
ansible_python_interpreter: /var/python/bin/python | ||
|
||
# Any valid nscli command works | ||
nscli_command: "show ns ip" | ||
|
||
|
||
tasks: | ||
- name: Run nscli command | ||
ansible.builtin.command: "nscli -s -U :nsroot:{{ nitro_pass }} {{ nscli_command }}" | ||
no_log: true | ||
changed_when: false | ||
register: nscli_output | ||
|
||
# Actually insecure for production environments since it will show the nitro_pass variable value. | ||
# Used here for demonstration purposes only. | ||
- name: Show nscli output | ||
ansible.builtin.debug: | ||
msg: "{{ nscli_output }}" |
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,28 @@ | ||
--- | ||
- name: Ansible ssh playbook | ||
hosts: demo_netscalers | ||
gather_facts: false | ||
tasks: | ||
- name: Calling shell module | ||
connection: netscaler.adc.ssh_netscaler_adc | ||
remote_user: nsroot | ||
vars: | ||
ansible_python_interpreter: /var/python/bin/python | ||
ansible.builtin.command: "echo hello" | ||
changed_when: false | ||
register: echo_result | ||
|
||
- name: Show command output | ||
ansible.builtin.debug: | ||
msg: "{{ echo_result }}" | ||
|
||
- name: Setup server | ||
delegate_to: localhost | ||
netscaler.adc.server: | ||
nsip: "{{ ansible_host }}" | ||
nitro_user: "{{ remote_user }}" | ||
nitro_pass: "{{ nitro_pass }}" | ||
validate_certs: false | ||
|
||
name: test-server-1 | ||
ipaddress: 192.168.2.2 |
34 changes: 34 additions & 0 deletions
34
examples/ssh_connections/override_netscaler_adc_tasks.yaml
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,34 @@ | ||
--- | ||
- name: Ansible ssh playbook | ||
hosts: demo_netscalers | ||
connection: netscaler.adc.ssh_netscaler_adc | ||
remote_user: nsroot | ||
gather_facts: false | ||
|
||
|
||
vars: | ||
ansible_python_interpreter: /var/python/bin/python | ||
|
||
tasks: | ||
- name: Calling shell module | ||
ansible.builtin.command: "echo hello" | ||
changed_when: false | ||
register: echo_result | ||
|
||
- name: Show command output | ||
ansible.builtin.debug: | ||
msg: "{{ echo_result }}" | ||
|
||
- name: Setup server | ||
delegate_to: localhost | ||
# vars: | ||
# # Path of python executable in controlling machine | ||
# ansible_python_interpreter: /usr/bin/python | ||
netscaler.adc.server: | ||
nsip: "{{ ansible_host }}" | ||
nitro_user: "{{ remote_user }}" | ||
nitro_pass: "{{ nitro_pass }}" | ||
validate_certs: false | ||
|
||
name: test-server-1 | ||
ipaddress: 192.168.2.2 |
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,42 @@ | ||
# | ||
# Execute like: ansible-playbook show_tech_support.yml -i hosts | ||
# | ||
--- | ||
- name: Ansible ssh playbook | ||
hosts: demo_netscalers | ||
remote_user: nsroot | ||
connection: netscaler.adc.ssh_netscaler_adc | ||
gather_facts: false | ||
vars: | ||
ansible_python_interpreter: /var/python/bin/python | ||
|
||
|
||
tasks: | ||
- name: Generate technical support bundle | ||
changed_when: false | ||
ansible.builtin.command: "nscli -s -U :nsroot:{{ nitro_pass }} show techsupport" | ||
register: sts_output | ||
no_log: true | ||
|
||
- name: Parse output to find tarball path | ||
ansible.builtin.set_fact: | ||
sts_bundle: >- | ||
{{ | ||
(sts_output.stdout_lines | ||
| select('search', 'points to') | ||
| list | ||
| first) | ||
.split('points to --->')[1] | ||
| trim | ||
}} | ||
- name: Download STS Bundle locally | ||
changed_when: false | ||
ansible.builtin.fetch: | ||
src: "{{ sts_bundle }}" | ||
dest: "my_ns_sts" | ||
|
||
- name: Show STS Bundle path | ||
ansible.builtin.debug: | ||
msg: "STS Bundle downloaded locally into the following directory: ./my_ns_sts{{ sts_bundle }}" |
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
Oops, something went wrong.