[ansible-project] How report the unreachable and failure condition.

2020-06-29 Thread Flavio Gobber
Hello,

I need to get with a external command the result of execution on a 
scheduled template, the report must include the hosts where was executed an 
if the host was unreachable.

How can I do it ?.

Thank you for help.

Best reards.

Flavio Gobber

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/bebf1c79-0458-44fb-9f91-ba75b65731d3o%40googlegroups.com.


[ansible-project] Re: List/Dictionary - Combine elements based on item value

2020-06-29 Thread Adam McGill
Figured out how to merge the lists based on values in each list.  

- name: merge lists
  set_fact:
merged_list: "{{ merged_list|default([]) + [{ 
  'name': item[0].name, 
  'size_available': item[0].size_available,
  'size_avaliable_80': item[0].size_avaliable_80,
  'size_total': item[0].size_total,
  'size_total_80': item[0].size_total_80,
  'size_used': item[0].size_used,
  'node_name': item[0].node_name,
  'percent_used_capacity': item[0].percent_used_capacity,
  'current_node': item[1].current_node,
  'address': item[1].address,
  'address4oct': item[1].address4oct,
  'failover_group': item[1].failover_group,
  'data_protcol': item[1].data_protcol| default(''),
  'role': item[1].role,
  'vserver': item[1].vserver
  }] }}"
  when: "item[0].node_name == item[1].current_node"
  loop: "{{ query('nested', aggregate_info, net_interface) }}"

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/01462f09-0bea-4274-81a4-825e1ad10f65o%40googlegroups.com.


[ansible-project] Re: List/Dictionary - Combine elements based on item value

2020-06-29 Thread Adam McGill
Adding further to above, i know i can get the value i want by doing this.

- debug:
msg: "{% for address in net_interface if address.node_name == 
'IQ-REG_NA_CLUSTER_01-01' %}{{ address.address }}{% endfor %}"

Anyway to add that logic when creating the aggregate_info list. for 
example, but when trying to do this i get a template error.  Don't know if 
its possible to do or i am missing something with my syntax.

- name: Get_Aggregate_Info
  #no_log: True
  set_fact:
aggregate_info: "{{ aggregate_info | 
  d([]) + [ {
  'name': item.value.aggregate_name, 
  'size_available': item.value.aggr_space_attributes.size_available 
| int,
  'size_avaliable_80%': 
(((item.value.aggr_space_attributes.size_total | int) * 0.8) - 
(item.value.aggr_space_attributes.size_used | int)) | round | int,
  'size_total': item.value.aggr_space_attributes.size_total | int,
  'size_total_80%': ((item.value.aggr_space_attributes.size_total | 
int) * 0.8 ) | round | int,
  'size_used': item.value.aggr_space_attributes.size_used | int,
  'node_name': item.value.nodes.node_name,
  'percent_used_capacity': 
item.value.aggr_space_attributes.percent_used_capacity
  'test': {% for address in net_interface if address.node_name == 
item.value.nodes.node_name %}{{ address.address }}{% endfor %}
  } ] }}" 
  with_items: "{{ netapp_info.ontap_info.aggregate_info | dict2items }}"
  when:
- ('agg_' in item.value.aggregate_name)

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/9de97bc8-8a90-4fc7-bc36-813623297b54o%40googlegroups.com.


[ansible-project] List/Dictionary - Combine elements based on item value

2020-06-29 Thread Adam McGill
Hello,
Basically want to add the items of net_interface into aggregate_info or 
create new list/dictionary based on key value of node_name.  Looking for 
assistance on how i can achieve this please and thank you.
Outcome of what want it listed below.

*list called: aggregate_info*
{
  "name": "agg_Data1_Cluster01",
   "node_name": "TEST_NA_CLUSTER_01-01",
   "percent_used_capacity": "46",
   "size_available": 8141263818752,
   "size_avaliable_80%": 5122753242726,
   "size_total": 15092552880128,
   "size_total_80%": 12074042304102,
   "size_used": 6951289061376
},
{
   "name": "agg_Data1_Cluster02",
   "node_name": "TEST_NA_CLUSTER_01-02",
   "percent_used_capacity": "34",
   "size_available": 5116275568640,
   "size_avaliable_80%": 3561215869747,
   "size_total": 7775298494464,
   "size_total_80%": 6220238795571,
   "size_used": 2659022925824
}

*list called: net_interface*
{
"address": "XX.XXX.X.XXX",
"address4oct": "224",
"data_protcol": "none",
"failover_group": "Management",
"node_name": "TEST_NA_CLUSTER_01-01",
"role": "node_mgmt",
"vserver": "TEST_NA_CLUSTER_01"
},
{
"address": "XX.XXX.X.XXX",
"address4oct": "226",
"data_protcol": "none",
"failover_group": "Management",
"node_name": "IQ-REG_NA_CLUSTER_01-02",
"role": "node_mgmt",
"vserver": "TEST_NA_CLUSTER_01"
}


*Out Come want:*
Dictionary called: aggregate_info (original) or new name
{
  "name": "agg_Data1_Cluster01",
   "node_name": "TEST_NA_CLUSTER_01-01",
   "percent_used_capacity": "46",
   "size_available": 8141263818752,
   "size_avaliable_80%": 5122753242726,
   "size_total": 15092552880128,
   "size_total_80%": 12074042304102,
   "size_used": 6951289061376
   "address": "XX.XXX.X.XXX",
   "address4oct": "224",
   "data_protcol": "none",
   "failover_group": "Management",
   "role": "node_mgmt",
   "vserver": "TEST_NA_CLUSTER_01"
},
{
   "name": "agg_Data1_Cluster02",
   "node_name": "TEST_NA_CLUSTER_01-02",
   "percent_used_capacity": "34",
   "size_available": 5116275568640,
   "size_avaliable_80%": 3561215869747,
   "size_total": 7775298494464,
   "size_total_80%": 6220238795571,
   "size_used": 2659022925824
   "address": "XX.XXX.X.XXX",
   "address4oct": "226",
   "data_protcol": "none",
   "failover_group": "Management",
   "role": "node_mgmt",
   "vserver": "TEST_NA_CLUSTER_01"
}

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/88a09aba-0455-4099-8efc-e6318198e12bo%40googlegroups.com.


[ansible-project] Combine dictionaries based on a dictionary key value.

2020-06-29 Thread Adam McGill
Hello,
Basically want to add the items of net_interface into aggregate_info or 
create new dictionary based on key value of node_name.  Looking for 
assistance on how i can achieve this please and thank you.

*Dictionary called: aggregate_info*
{
  "name": "agg_Data1_Cluster01",
   "node_name": "TEST_NA_CLUSTER_01-01",
   "percent_used_capacity": "46",
   "size_available": 8141263818752,
   "size_avaliable_80%": 5122753242726,
   "size_total": 15092552880128,
   "size_total_80%": 12074042304102,
   "size_used": 6951289061376
},
{
   "name": "agg_Data1_Cluster02",
   "node_name": "TEST_NA_CLUSTER_01-02",
   "percent_used_capacity": "34",
   "size_available": 5116275568640,
   "size_avaliable_80%": 3561215869747,
   "size_total": 7775298494464,
   "size_total_80%": 6220238795571,
   "size_used": 2659022925824
}

*Dictionary called: net_interface*
{
"address": "XX.XXX.X.XXX",
"address4oct": "224",
"data_protcol": "none",
"failover_group": "Management",
"node_name": "TEST_NA_CLUSTER_01-01",
"role": "node_mgmt",
"vserver": "TEST_NA_CLUSTER_01"
},
{
"address": "XX.XXX.X.XXX",
"address4oct": "226",
"data_protcol": "none",
"failover_group": "Management",
"node_name": "IQ-REG_NA_CLUSTER_01-02",
"role": "node_mgmt",
"vserver": "TEST_NA_CLUSTER_01"
}


*Out Come want:*
Dictionary called: aggregate_info (original) or new name
{
  "name": "agg_Data1_Cluster01",
   "node_name": "TEST_NA_CLUSTER_01-01",
   "percent_used_capacity": "46",
   "size_available": 8141263818752,
   "size_avaliable_80%": 5122753242726,
   "size_total": 15092552880128,
   "size_total_80%": 12074042304102,
   "size_used": 6951289061376
   "address": "XX.XXX.X.XXX",
   "address4oct": "224",
   "data_protcol": "none",
   "failover_group": "Management",
   "role": "node_mgmt",
   "vserver": "TEST_NA_CLUSTER_01"
},
{
   "name": "agg_Data1_Cluster02",
   "node_name": "TEST_NA_CLUSTER_01-02",
   "percent_used_capacity": "34",
   "size_available": 5116275568640,
   "size_avaliable_80%": 3561215869747,
   "size_total": 7775298494464,
   "size_total_80%": 6220238795571,
   "size_used": 2659022925824
   "address": "XX.XXX.X.XXX",
   "address4oct": "226",
   "data_protcol": "none",
   "failover_group": "Management",
   "role": "node_mgmt",
   "vserver": "TEST_NA_CLUSTER_01"
}

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/311d6e78-ec37-48a2-84d4-04ef115e0021o%40googlegroups.com.


[ansible-project] Reboot servers strategy.

2020-06-29 Thread Rafael Tomelin
Hi Guys,
I have periodic updates on all RedHat servers at the same time, I need to
create a strategy to restart my clusters because I can't stop my
application and services.

How to create the reboot strategy server-per-server in clusters?


-- 
Atenciosamente,

Rafael Tomelin
Tel.: 51-984104084
Skype: rafael.tomelin

LPI ID: LPI000191271
Red Hat Certified Engineer
Puppet Professional 2017 Certification

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAGEUqbAwBVcpuWsULocMZ2ts4-298wqjmkkEvhRhRSDaFdnHPQ%40mail.gmail.com.


[ansible-project] Re: Ansible tower webhook notification

2020-06-29 Thread Bill Crupi


On Thursday, June 25, 2020 at 1:58:18 PM UTC-4, Jam Volkov wrote:
>
> Hi All,
>
> I'm testing a webhook notification from Ansible tower, it works good
> Received data example:
>
> {"id": 14, "name": "job_test", "url": "
> https://ansibletower/#/jobs/playbook/14;, "created_by": "admin", 
> "started": "2020-06-25T09:14:13.804517+00:00", "finished": null, "status": 
> "running", "traceback": "", "inventory": "inv", "project": "test", 
> "playbook": "hello_world.yml", "credential": null, "limit": "", 
> "extra_vars": "{}", "hosts": {}}
>
> Question: Can I put information from playbook (ex. hello_world.yml) into 
> json body of the notification(example above)? (I tried to customize the 
> json body but it doesn't work)
>
> Do you know how to go from netbox webhooks to ansibe tower?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/481f2b78-a2c8-453c-beea-bbfd08d2a6ceo%40googlegroups.com.


[ansible-project] How to print only the failed telnet connections from my localhost

2020-06-29 Thread Shifa Shaikh
Below is my playbook that helps check telnet connections from my localhost 
to all remote hosts.

   - wait_for:

   host: "{{ item }}"

   port: 22

   state: started # Port should be open

   delay: 0   # No wait before first check (sec)

   timeout: 2 # Stop checking after timeout (sec)

 ignore_errors: yes

 register: netstatoutput

 delegate_to: localhost

 with_items: "{{ groups['all_hosts'] }}"


I get a lot of unnecessary stuff dumped in the logs when i debug like below:

   - debug:

   msg: "{{ netstatoutput }}"

I just need all the failed telnet  IPs  printed in the debug and nothing 
else like below:

  "msg": "Timeout when waiting for 10.9.172.62:22 
"
  "msg": "Timeout when waiting for 10.9.72.66:22 
"
  "msg": "Timeout when waiting for 10.9.172.42:22 
"



Can you please suggest how can I? 

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/0c3bfb5c-333f-47dc-93a9-de1eba18bfe9o%40googlegroups.com.


[ansible-project] Unable to unarchive the openshift client

2020-06-29 Thread Vinay Kumar Rudiya
If I'm trying to unarchive only the file out of the role I can do it, but 
when I'm trying to do in role with the proxy its causing error
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to find 
handler for 
\"/home/.ansible/tmp/ansible-tmp-1593453017.73-12268-16009161025458/openshift-client-linux.tar1fwzbnm7.gz\".
 
Make sure the required command to extract the file is installed. Command 
\"/usr/bin/gtar\" could not handle archive. Command \"/usr/bin/unzip\" 
could not handle archive."}

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/9b31ef79-2284-4419-a1ac-1898431d9d3en%40googlegroups.com.


[ansible-project] Ansible async and SIGHUP with shell module

2020-06-29 Thread Sarah Weissman
Hi all,

I'm trying to understand what happens when a shell command exits in ansible 
in sync vs. async modes. It seems that in the former case there is a SIGHUP 
sent and in the latter there isn't. To test this I created a startup script 
for a background process that runs forever:

start_run_forever.sh:
- - - - - - - - - - - - -

#!/usr/bin/bash


strace -o ~/debug-start sh /home/asb_service/run_forever.sh &

echo "Done"
- - - - - - - - - - - - -
run_forever.sh:

- - - - - - - - - - - - -

#!/usr/bin/bash


while true

do

echo "here"

sleep 5

done
- - - - - - - - - - - - -

When I run an ad-hoc command synchronously, the run_forever.sh script 
starts and then receives a SIGHUP when the terminal exits, as I'd expect.

ansible -vvv {myhost} -i environments/dev -m shell -a 
"~/start_run_forever.sh" -u {myuser}


strace output:

...
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0 
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0 
rt_sigaction(SIGINT, {sa_handler=0x43e910, sa_mask=[], sa_flags=SA_RESTORER, 
sa_restorer=0x7f60b1587400}, {sa_handler=SIG_IGN, sa_mask=[], 
sa_flags=SA_RESTORER, sa_restorer=0x7f60b158740 0}, 8) = 0 
rt_sigaction(SIGINT, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER, 
sa_restorer=0x7f60b1587400}, {sa_handler=0x43e910, sa_mask=[], 
sa_flags=SA_RESTORER, sa_restorer=0x7f60b158740 0}, 8) = 0 
wait4(-1, [{WIFSIGNALED(s) && WTERMSIG(s) == SIGHUP}], 0, NULL) = 22102 
--- SIGHUP {si_signo=SIGHUP, si_code=SI_KERNEL} --- 
+++ killed by SIGHUP +++


but when I run in async mode it never receives the SIGHUP and keeps 
running, which I would not expect to happen.

ansible -B 10 -P 5 -vvv {myhost} -i environments/dev -m shell -a 
"~/start_run_forever.sh" -u {myuser}

strace output:

...
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 22395
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=22395, si_uid=2153, 
si_status=0, si_utime=0, si_stime=0} ---
wait4(-1, 0x7ffcd93f6010, WNOHANG, NULL) = -1 ECHILD (No child processes)
rt_sigreturn({mask=[]}) = 0
rt_sigaction(SIGINT, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER, 
sa_restorer=0x7fb5e2e1d400}, {sa_handler=SIG_IGN, sa_mask=[], 
sa_flags=SA_RESTORER, sa_restorer=0x7fb5e2e1d40\
0}, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
write(1, "here\n", 5)   = -1 EPIPE (Broken pipe)
...


I've tried this with 2.5.0 and 2.6.4 and the behavior is the same. I know 
the right way to start a background process is to use "nohup" but 
developers on our project were relying on this behavior of async to start 
background processes in production code. At this point I am just curious 
whether it's a feature or a bug in ansible because I can't find any 
documentation about this.

Thanks,
Sarah




-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/9d7ed45f-92c0-4b48-8675-82d8afb8816fo%40googlegroups.com.


[ansible-project] Ansible unable to create $HOME/.ansible/tmp directory due to shell syntax error in RHEL 6.7

2020-06-29 Thread Rishabh Kumar
Hi,

When I am trying to run ansible job from my host computer to remote server 
it fails with the following error logs -


<127.0.0.12> ESTABLISH SSH CONNECTION FOR USER: ansibleuser



<127.0.0.12> SSH: EXEC sshpass -d47 ssh -vvv -C -o ControlMaster=auto -o 
ControlPersist=60s -o 'User="ansibleuser"' -o ConnectTimeout=10 -o 
ControlPath=/Users/hostuser/.ansible/cp/0ac5f07217 127.0.0.12 '/bin/sh -c 
'"'"'( umask 77 && mkdir -p "` echo /home/ansibleuser/.ansible/tmp `"&& 
mkdir 
/home/ansibleuser/.ansible/tmp/ansible-tmp-1593435394.159632-95806-14486735064275
 
&& echo ansible-tmp-1593435394.159632-95806-14486735064275="` echo 
/home/ansibleuser/.ansible/tmp/ansible-tmp-1593435394.159632-95806-14486735064275
 
`" ) && sleep 0'"'"''

<127.0.0.12> (1, b'\x1b(B\x1b[m', b'OpenSSH_7.9p1, LibreSSL 
2.7.3\r\ndebug1: Reading configuration data 
/Users/hostuser/.ssh/config\r\ndebug1: /Users/hostuser/.ssh/config line 1: 
Applying options for *\r\ndebug1: Reading configuration data 
/etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 48: Applying 
options for *\r\ndebug2: resolve_canonicalize: hostname 127.0.0.12 is 
address\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting 
O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 
4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 
remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: 
mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: 
done pid = 95817\r\ndebug3: mux_client_request_session: session request 
sent\r\n/bin/sh: -c: line 0: syntax error near unexpected token 
`(\'\n/bin/sh: -c: line 0: `( umask 77 && mkdir -p "` echo 
\x1b(B\x1b[m/home/ansibleuser/.ansible/tmp `"&& mkdir 
\x1b(B\x1b[m/home/ansibleuser/.ansible/tmp/ansible-tmp-1593435394.159632-95806-14486735064275
 
&& echo ansible-tmp-1593435394.159632-95806-14486735064275="` echo 
\x1b(B\x1b[m/home/ansibleuser/.ansible/tmp/ansible-tmp-1593435394.159632-95806-14486735064275
 
`" ) && sleep 0\'\ndebug3: mux_client_read_packet: read header failed: 
Broken pipe\r\ndebug2: Received exit status from master 1\r\n')

<127.0.0.12> Failed to connect to the host via ssh: OpenSSH_7.9p1, LibreSSL 
2.7.3

debug1: Reading configuration data /Users/hostuser/.ssh/config

debug1: /Users/hostuser/.ssh/config line 1: Applying options for *

debug1: Reading configuration data /etc/ssh/ssh_config

debug1: /etc/ssh/ssh_config line 48: Applying options for *

debug2: resolve_canonicalize: hostname 127.0.0.12 is address

debug1: auto-mux: Trying existing master

debug2: fd 3 setting O_NONBLOCK

debug2: mux_client_hello_exchange: master version 4

debug3: mux_client_forwards: request forwardings: 0 local, 0 remote

debug3: mux_client_request_session: entering

debug3: mux_client_request_alive: entering

debug3: mux_client_request_alive: done pid = 95817

debug3: mux_client_request_session: session request sent

/bin/sh: -c: line 0: syntax error near unexpected token `('

/bin/sh: -c: line 0: `( umask 77 && mkdir -p "` echo 
/home/ansibleuser/.ansible/tmp `"&& mkdir 
/home/ansibleuser/.ansible/tmp/ansible-tmp-1593435394.159632-95806-14486735064275
 
&& echo ansible-tmp-1593435394.159632-95806-14486735064275="` echo 
/home/ansibleuser/.ansible/tmp/ansible-tmp-1593435394.159632-95806-14486735064275
 
`" ) && sleep 0'

debug3: mux_client_read_packet: read header failed: Broken pipe

debug2: Received exit status from master 1

fatal: [127.0.0.12]: UNREACHABLE! => {

"changed": false,

"msg": "Failed to create temporary directory.In some cases, you may 
have been able to authenticate and did not have permissions on the target 
directory. Consider changing the remote tmp path in ansible.cfg to a path 
rooted in \"/tmp\", for more error information use -vvv. Failed command 
was: ( umask 77 && mkdir -p \"` echo 
\u001b(B\u001b[m/home/ansibleuser/.ansible/tmp `\"&& mkdir 
\u001b(B\u001b[m/home/ansibleuser/.ansible/tmp/ansible-tmp-1593435394.159632-95806-14486735064275
 
&& echo ansible-tmp-1593435394.159632-95806-14486735064275=\"` echo 
\u001b(B\u001b[m/home/ansibleuser/.ansible/tmp/ansible-tmp-1593435394.159632-95806-14486735064275
 
`\" ), exited with result 1, stdout output: \u001b(B\u001b[m, stderr 
output: OpenSSH_7.9p1, LibreSSL 2.7.3\r\ndebug1: Reading configuration data 
/Users/hostuser/.ssh/config\r\ndebug1: /Users/hostuser/.ssh/config line 1: 
Applying options for *\r\ndebug1: Reading configuration data 
/etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 48: Applying 
options for *\r\ndebug2: resolve_canonicalize: hostname 127.0.0.12 is 
address\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting 
O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 
4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 
remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: 
mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: 
done pid = 95817\r\ndebug3: mux_client_request_session: 

[ansible-project] Re: Ansible expect module with Oracle SBC

2020-06-29 Thread Gerhard Van Der Wath
Hi Kai.

Trust you are well, we are testing adding new configs via Ansible on the 
SBC, just struggling, to handle the various prompt changes, as you navigate 
the different configuration levels, and I have tweaked the playbook, but 
not coming right.

Here is the below output. 

The full traceback is:
File 
"/tmp/ansible_expect_payload_zp_yu2yh/ansible_expect_payload.zip/ansible/modules/commands/expect.py",
 
line 123, in wrapped
fatal: [###]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"chdir": null,
"command": "ssh admin@##",
"creates": null,
"echo": false,
"removes": null,
"responses": {
"(?i)password": "",
"(configure)#": [
"media-manager realm-config"
],
"(realm-config)#": [
"identifier TEST_REALM_2",
"addr-prefix 10.1.0.0/29",
"network-interfaces PEER_F00:0",
"mm-in-realm disabled",
"mm-in-network enabled",
"mm-same-ip  disabled",
"mm-in-system enabled",
"access-control-trust-level medium",
"invalid-signal-threshold 1'",
"maximum-signal-threshold 4000",
"untrusted-signal-threshold  0",
"options sip-connect-pbx-reg",
"qos-enable enabled",
"accounting-enable enabled",
"done",
"quit"
],
"HA1#": [
"save-config",
"verify-confog",
"activate-config"
]
},
"timeout": 30
}
},
"msg": "No remaining responses for 'HA1#', output was ' 
activate-config\r\nActivate-Config received, processing.\r\nwaiting for 
request to finish\r\nRequest to 'ACTIVATE-CONFIG' has Finished, 
\r\nActivate Complete\r\nLABHA1#'"
}
...ignoring


Here is my playbook:

- name: Add config centrex child realm
  hosts: 10.11.171.20
  connection: local
  gather_facts: yes


  tasks:

  - name: Add config
expect:
  command: ssh admin@##
  responses:
   (?i)password: "##"
   'HA1#':
   - conf t
   '(configure)#':
   - media-manager realm-config
   '(realm-config)#':
   - identifier TEST_REALM_2
   - addr-prefix 10.1.0.0/29
   - network-interfaces PEER_F00:0
   - mm-in-realm disabled
   - mm-in-network enabled
   - mm-same-ip  disabled
   - mm-in-system enabled
   - access-control-trust-level medium
   - invalid-signal-threshold 1'
   - maximum-signal-threshold 4000
   - untrusted-signal-threshold  0
   - options sip-connect-pbx-reg
   - qos-enable enabled
   - accounting-enable enabled
   - done
   - quit
   'HA1#':
   - save-config
   - verify-confog
   - activate-config
ignore_errors: true
register: labsbc

  - debug: var=labsbc.stdout_lines

On Wednesday, 5 February 2020 11:05:57 UTC+2, Gerhard Van Der Wath wrote:
>
> Hi.
>
> I am having an issue with Ansible's expect module.
>
> I am trying to run simple commands on a Oracle SBC, but getting some 
> errors.
>
> Playbook:
>
> - name: Check CPU
> hosts: all
> connection: local
> gather_facts: yes
>
>
> tasks:
>
> - name: Get CPU load
> expect:
> command: ssh admin@#
> responses:
> 'password: ':
> - ###
> '#':
> - sh platform cpu-load
>
>
>
> Error:
>
> fatal: [##]: FAILED! => { "changed": false, "invocation": { 
> "module_args": { "chdir": null, "command": "ssh admin@##", "creates": 
> null, "echo": false, "removes": null, "responses": { "#": [ "sh platform 
> cpu-load" ], "password: ": [ "##" ] }, "timeout": 30 } }, "msg": "No 
> remaining responses for '#', output was ' sh platform 
> cpu-load\r\nTimestamp: 10:49:41 Wed 2020-02-05\r\nTotal load : 4%\r\nCPU 00 
> load : 5%\r\nCPU 01 load : 3%\r\nCPU 02 load : 5%\r\nCPU 03 load : 
> 5%\r\nVOXBDLHA1#'" } 
>
> I #ed out the IP and password
>
> Your assistance will be appreciated.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/84dc791c-65a2-4df2-9878-3ad805cc2b4eo%40googlegroups.com.