[ansible-project] Ansible Playbook running for longtime/indefinitely for windows 2012 R2 Ansible Playbook

2018-03-07 Thread Namasivayam C



I am new to Ansible and I'm trying to configure windows 2012 R2 from RHEL 7 
Ansible Node. I'm able to establish connection between them using Winrm 
Credssp. Below is /etc/ansible/group_vars/windows.yml file


COMPONENT NAME
urllib3.connectionpool https://192.168.2.211:5986 "POST /wsman HTTP/1.1" 
500 1320


ANSIBLE VERSION
ansible 2.3.1.0

python version = 2.7.5


ansible_user: admin
ansible_password: XXX
ansible_winrm_scheme: https
ansible_winrm_transport: credssp
ansible_port: 5986
ansible_connection: winrm
ansible_winrm_server_cert_validation: ignore
validate_certs: false

When I execute win_ping module for testing connection from Ansible node to 
Windows 2012 R2 server it was successful.

[root@Ansible-Server playbooks]# ansible windows -m win_ping
XX.XX.XX.XX | SUCCESS => {
"changed": false,
"ping": "pong"
}

But When I have tried executing Windows 2012 R2 playbook file, after 
submitting ansible-playbook playbook.yml command, it is continuously 
waiting for indefinite time, as It is not completing.

Below is the log that is constantly displaying same. Waiting continuously. 
/var/log/ansible/log

2018-03-07 19:34:14,255 urllib3.connectionpool https://192.168.2.211:5986 "POST 
/wsman HTTP/1.1" 500 1320
2018-03-07 19:34:34,256 urllib3.connectionpool https://192.168.2.211:5986 "POST 
/wsman HTTP/1.1" 500 1320
2018-03-07 19:34:54,256 urllib3.connectionpool https://192.168.2.211:5986 "POST 
/wsman HTTP/1.1" 500 1320
2018-03-07 19:35:14,258 urllib3.connectionpool https://192.168.2.211:5986 "POST 
/wsman HTTP/1.1" 500 1320
2018-03-07 19:35:34,257 urllib3.connectionpool https://192.168.2.211:5986 "POST 
/wsman HTTP/1.1" 500 1320
2018-03-07 19:35:54,272 urllib3.connectionpool https://192.168.2.211:5986 "POST 
/wsman HTTP/1.1" 500 1320
2018-03-07 19:36:14,272 urllib3.connectionpool https://192.168.2.211:5986 "POST 
/wsman HTTP/1.1" 500 1320
2018-03-07 19:36:34,273 urllib3.connectionpool https://192.168.2.211:5986 "POST 
/wsman HTTP/1.1" 500 1320
2018-03-07 19:36:54,273 urllib3.connectionpool https://192.168.2.211:5986 "POST 
/wsman HTTP/1.1" 500 1320
2018-03-07 19:37:14,273 urllib3.connectionpool https://192.168.2.211:5986 "POST 
/wsman HTTP/1.1" 500 1320
2018-03-07 19:37:34,273 urllib3.connectionpool https://192.168.2.211:5986 "POST 
/wsman HTTP/1.1" 500 1320
2018-03-07 19:37:54,274 urllib3.connectionpool https://192.168.2.211:5986 "POST 
/wsman HTTP/1.1" 500 1320
2018-03-07 19:38:14,274 urllib3.connectionpool https://192.168.2.211:5986 "POST 
/wsman HTTP/1.1" 500 1320
2018-03-07 19:38:34,274 urllib3.connectionpool https://192.168.2.211:5986 "POST 
/wsman HTTP/1.1" 500 1320
2018-03-07 19:38:54,274 urllib3.connectionpool https://192.168.2.211:5986 "POST 
/wsman HTTP/1.1" 500 1320

above log continues/updates same for every 20 sec.

Could you please any one suggest where it' got stuck and how i can identify 
and troubleshoot .



-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/2259051b-823c-4dfc-9080-ff8b863f54e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: os_nova_flavor does not update a flavor if it already exists...

2018-03-07 Thread Arun prasath
Raised a PR for this issue - https://github.com/ansible/ansible/pull/37170

On Monday, 18 April 2016 17:35:48 UTC+5:30, David Shrewsbury wrote:
>
> I just realized that someone could probably add the logic to compare the 
> current flavor
> and the parameters and, if different, do the delete/create to simulate the 
> update. I'd be
> happy to merge such a change if you wanted to propose it.  I could add it 
> to my list of
> changes to do, but it would be low priority.
>
>
>
> On Sunday, April 17, 2016 at 7:28:57 PM UTC-4, David Shrewsbury wrote:
>>
>> Looks to me like horizon just does a delete/create. So it's the same as 
>> your workaround.
>>
>>
>> https://github.com/openstack/horizon/blob/b0f3ec3ace531c110f328d208cded302d2617f88/openstack_dashboard/dashboards/admin/flavors/workflows.py#L304-L309
>>
>>
>>
>> On Sunday, April 17, 2016 at 6:13:21 PM UTC-4, Thiago Martins wrote:
>>>
>>> Mmm... Interesting...
>>>
>>> How it is done via Horizon? Since I can manually update the flavors via 
>>> Web GUI...
>>>
>>> Don't you think that Shade / Ansible can somehow, mimic Horizon "flavor 
>>> update feature"?
>>>
>>> On Sunday, April 17, 2016 at 6:27:46 PM UTC-3, David Shrewsbury wrote:

 The Nova API does not have any way to update flavors. Because of this, 
 the Ansible
 module does not support updating.



 On Sunday, April 17, 2016 at 11:52:30 AM UTC-4, Thiago Martins wrote:
>
> Guys,
>
>  I'm trying to update the default OpenStack flavors, by using 
> "os_nova_flavor" but, it does not update the flavors settings if it 
> already 
> exists...
>
>  Is there any way to force it to update the flavors?
>
>  A workaround is to first, delete the flavors, and then, create it 
> again. But this is bad because every time I run Ansible, it will delete 
> and 
> recreate the flavors over and over again.
>
>  My intention is to update the flavors, only if it is different. For 
> example:
>
> ---
> - name: nova updating m1.small flavor
>   environment: "{{admin_openrc_env}}"
>   os_nova_flavor:
> state=present
> name=m1.small
> ram=2048
> swap=1024
> vcpus=2
> disk=20
> ephemeral=4
> ---
>
>  I was thinking that, if "m1.small" flavor doesn't have those 
> settings, it sill be "changed", otherwise, if it already have those 
> settings, it will "not be changed / green Ansible ok".
>
>  Is there any way to make it behaves like this?
>
> Thanks!
> Thiago
>


-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/2f058ab1-eb93-407f-9e64-329e291bc848%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Howto read variables from an vaut encrypted file

2018-03-07 Thread neccross9
Hi Brian,

of course not. it's supposed to be the value of 'root_pass_sirus' ...

Am Donnerstag, 8. März 2018 01:13:24 UTC+1 schrieb Brian Coca:
>
> Ansilbe reads the 'root_pass_sirus' variable fine, the problem is that 
> 'TesT1234' variable isn't defined anywhere. 
>
>
> -- 
> -- 
> Brian Coca 
>

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/fb17c895-772f-4e03-a8fe-dc41cdf7b8e2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Using the wait_for module to check ports from one windows host to another windows host

2018-03-07 Thread Jordan Borean
The wait_for module is a Python module and can't be run on a Windows host. 
You can either delegate to the localhost (Ansible controller) and run it 
from there, or use the win_wait_for module which was added in Ansible 2.4 
https://docs.ansible.com/ansible/2.4/win_wait_for_module.html.

Thanks

Jordan

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ccbdb038-a61d-461c-b2a9-501e11ea850e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Ansible Disk Usage and Disk Space Full Alert generation Script.

2018-03-07 Thread Kiran Shrimali
Hi,

I am tryig to write an Ansible script which will Generat Alert on Disk 
Usage. Once the Disk Usage goes above the Threshold, alert will be 
generated. 

Below is start up code.

---
 - hosts: "{{ hostGroup }}"
   user: gamesroot
   become: true
   become_user: root
   gather_facts: no
   tasks:
   - shell: df -h "{{ item }}" | tail -n 1 | awk {'print $5 '}  | sed 
's/%//g'
 with_items:
  - /
  - /home
  - /backup
 register: test

   - debug:
   msg: "{{ test.results|map(attribute='stdout')|list }}"
   - name: Size is big
 shell: echo "tobig size "
 when: test.results > 20
~`

Here Problem isi  not able to Register Value and Compare it with Threshold. 

PLEASE help me for the SAME.

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/8c729828-c2ba-48fd-bca2-56f6b13f9ab8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Using the wait_for module to check ports from one windows host to another windows host

2018-03-07 Thread marcalfa1
Not sure if i'm using the wait_for module correctly on two windows host.  
I'm getting the error below when trying to check if a port is open from a 
source windows host to a target windows host.
Wondering if i'm using the module correctly or if this even possible when 
both hosts are windows.  I've tried the same playbook on two unix host and 
it worked.
  
---
- hosts: win-host1
  tasks:
- wait_for:
host: 192.168.70.13
port: 9443
timeout: 10
  ignore_errors: true
  register: result

- debug: var=result



PLAY [win-host1] 
***

TASK [Gathering Facts] 
***
ok: [win-host1]

TASK [wait_for] 
**
 [WARNING]: FATAL ERROR DURING FILE TRANSFER: Traceback (most recent call 
last):   File 
"/usr/lib/python2.6/site-packages/ansible/plugins/connection/winrm.py", 
line 276, in _winrm_exec
self._winrm_send_input(self.protocol, self.shell_id, command_id, data, 
eof=is_last)   File 
"/usr/lib/python2.6/site-packages/ansible/plugins/connection/winrm.py", 
line 256, in _winrm_send_input
protocol.send_message(xmltodict.unparse(rq))   File 
"/usr/lib/python2.6/site-packages/winrm/protocol.py", line 207, in 
send_message return self.transport.send_message(message)   File
"/usr/lib/python2.6/site-packages/winrm/transport.py", line 202, in 
send_message raise WinRMTransportError('http', error_message) 
WinRMTransportError: (u'http', u'Bad HTTP response returned
from server. Code 500')

fatal: [win-host1]: FAILED! => {"msg": "winrm send_input failed"}
...ignoring

TASK [debug] 
*
ok: [win-host1] => {
"result": {
"failed": true,
"msg": "winrm send_input failed"
}
}

PLAY RECAP 
***
win-host1: ok=3changed=0unreachable=0failed=0

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/fcbc0bdf-424b-41ce-a69c-9cfff16c72fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Howto read variables from an vaut encrypted file

2018-03-07 Thread Brian Coca
Ansilbe reads the 'root_pass_sirus' variable fine, the problem is that
'TesT1234' variable isn't defined anywhere.


-- 
--
Brian Coca

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CACVha7ca0zQh0m5L6bF31gh-sriqvbMAMYarPgotY_P8CZ0peA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: psycog2 is installed but postgresql_user gives error that psycog2 is required

2018-03-07 Thread gearoidibm
I found that with /usr/bin/python I cannot import psycopg2, but with 
/usr/local/bin/python I can.  Guess there's two python envs on my managed 
host.

On Wednesday, 7 March 2018 22:00:17 UTC, gearo...@gmail.com wrote:
>
> psycog2 has beeen installed using ansible pip module.
>
> The postgresql_user module fails with a message saying psycog2 is required.
>
> pip list shows that psycog2 is installed on the managed system.
> ansible 2.4.3, python 2.7.10 
> managed system is rhel 7.4
>
> Have I missed something ?
>
>

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/8b6b5094-0c85-4980-a9ff-be5f9acbd2ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: win_get_url always failing first time

2018-03-07 Thread Jordan Borean
I'm not sure, there is no difference between the first and second execution 
from an Ansible perspective, you are best off trying to replicate the issue 
reliably. Things to look for

* Whether it is failing at a certain point in the day (is the server under 
load at this time)
* Whether it is the same file
* Whether this is happening on different sites
* Whether this is happening on different Windows hosts

>From there you can hopefully narrow down a set of circumstances that will 
allow you to replicate the issue reliably and then ultimately find the 
cause.

Thanks

Jordan

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/21e94a83-bbea-4842-a92f-d52586b52c66%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] psycog2 is installed but postgresql_user gives error that psycog2 is required

2018-03-07 Thread gearoidibm
psycog2 has beeen installed using ansible pip module.

The postgresql_user module fails with a message saying psycog2 is required.

pip list shows that psycog2 is installed on the managed system.
ansible 2.4.3, python 2.7.10 
managed system is rhel 7.4

Have I missed something ?

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f7401708-7bb8-40ff-9b97-9d827164b43b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: win_get_url always failing first time

2018-03-07 Thread Thijn Bukkems
Thanks Jordan.

I'm running ansible 2.4.0.0 on CentOS trying to download a file using 
win_get_url like this

- name: Download file
  win_get_url:
   url: http://servername/Ansible/USA/file.zip
   dest: "{{ ansible_env.TEMP }}\\file.zip"
  when: zip_file.stat.exists == True


I can't find any entry in the server logs, and am mostly confused as to why 
it just happens the first time each day but not all others after that.

On Wednesday, 7 March 2018 13:15:24 UTC-8, Jordan Borean wrote:
>
> Are you able to share some more info like the Ansible version you are on, 
> the task you are running. A 500 status code means internal error (internal 
> to the http server) and usually indicates a problem on the remote end. You 
> need to be able to debug what is happened in the times of a 500 error to 
> determine what is happening, there is not much we can do from there.
>
> Thanks
>
> Jordan
>

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b12d7beb-ee7a-49b5-b1d7-2e4cccf95a9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: win_get_url always failing first time

2018-03-07 Thread Jordan Borean
Are you able to share some more info like the Ansible version you are on, 
the task you are running. A 500 status code means internal error (internal 
to the http server) and usually indicates a problem on the remote end. You 
need to be able to debug what is happened in the times of a 500 error to 
determine what is happening, there is not much we can do from there.

Thanks

Jordan

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b8ad5a9d-722a-4460-a570-f08d01a54137%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Howto read variables from an vaut encrypted file

2018-03-07 Thread neccross9
Hi all,

the following task may sound easy but actually it fails all the time ...

I want to store my password in a variable and put it into an ansible-vault 
encrypted file.
The content of this file will look like this:

---
root_pass_sirius: "{{ TesT1234 }}"

Now my check.yml shall read the encrypted file, get the password and login

---
- hosts: sirius
  remote_user: ansible
#  gather_facts: no
  become: yes
  become_method: su
  vars_files:
 - enc_vars.yml

  vars:
 ansible_become_pass: '{{ root_pass_sirius }}'


But the login fails with:

FAILED! => {
"msg": "The field 'become_pass' has an invalid value, which includes an 
undefined variable. The error was: {{ Test1234 }}: 'TesT1234' is 
undefined\nexception type: \nexception: {{ TesT1234 }}: 
'TesT1234' is undefined"
}

So it looks like ansible is unable to get the variable out of the encrypted 
file ... but WHY ?

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d71c7596-d7d4-435f-a4dd-dbec7ed369e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Copy module

2018-03-07 Thread Thijn Bukkems
My copy speeds greatly increased when I moved the package source to the 
same datacenter as the target resources. Could it be a location issue where 
your network speed gets throttled? 

On Tuesday, 6 March 2018 13:05:15 UTC-8, Malcolm Hussain-Gambles wrote:
>
> I'm using ansible to build a package in Jenkins and the make an rpm.
> The copy function takes 20+ minutes to copy a few files. Using the command 
> function takes under a second.
> The synchronize function is generally unusable (better off using rsync 
> from command)
>
> I was wondering what other people's experiences are with copy and 
> synchronize.
>

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/052914da-5ee7-4ba7-87de-d1da13f72c38%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: win_get_url always failing first time

2018-03-07 Thread Thijn Bukkems
P.s. I have already doubled the winrm read and action timeout in the 
group_vars but the issue persists. Any advice is welcome. When I browse the 
website manually from chrome it loads fine.

On Wednesday, 7 March 2018 08:46:51 UTC-8, Thijn Bukkems wrote:
>
> Hey guys,
>
> I run into an issue where my win_get_url always fails with the error "The 
> remote server returned an error: (500) Internal Server Error.", 
> "status_code": 500," the first time it is run each night. If I run the 
> playbook again a couple minutes later the files download successfully. Does 
> anyone have experience with this and can point me in the right direction 
> figuring this out? The server is available, as the second attempt works 
> flawlessly.
>
> Thanks
> Thijn
>
>
>

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/dcb1661f-96ee-4060-9866-13b4ad079927%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] apt_key hanging issues

2018-03-07 Thread David Jones
Hi I am stuck trying to get apt_key to download a key from a key server.  

Here is my code which just hags indefinitely.

- name: Get upstream APT GPG key
  apt_key:
id: "{{ docker_apt_key }}"
keyserver: "{{ key_server }}"
state: "present"

Here are my vars...
docker_apt_key: "9DC858229FC7DD38854AE2D88D81803C0EBFCD88"
key_server: "keyserver.ubuntu.com"


 
This script is created on the host.


/tmp/.ansible/tmp/ansible-tmp-1520452202.6258628-133739762258932/apt_key.py


When I run it manually with the verbosity turned up, I can see that it 
hangs after this line...


# code object from 
'/usr/lib/python3.4/encodings/__pycache__/cp437.cpython-34.pyc'

import 'encodings.cp437' # <_frozen_importlib.SourceFileLoader object at 
0x7ff409266828>



Any suggestions?


Thanks,


David

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f4dea0ef-3c46-4e30-94cf-66c61cc21e0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: ios_facts module unable to open shell [SOLVED]

2018-03-07 Thread Claudia de Luna
Exactly!  the IOS module is for switches and routers...I was going to point
you to the ASA modules if you were, in fact, working on a firewall but you
already found them!  That is a great idea!  Good luck with that!   I'm
doing similar things for my clients. From initial
provisioning/configuration (generating and applying) to testing and then
compliance reporting.  In a managed services environment it could be very
powerful!

On Wed, Mar 7, 2018 at 11:28 AM, Otto Nix  wrote:

> Hi Claudia,
>
> Thanks for responding. I think the target hardware was the problem (I
> should have put that in the original post) , but not sure. It's a Cisco ASA
> 5540 running 9.1(7)23. I just got this working using the asa_command module
> (which I didn't know existed). Is there a difference between Cisco IOS on
> an ASA? I have no idea, I'm the Linux guy, not the Network guy so...
>
> Below is the playbook I used to solve my problem:
> ---
> - hosts: ios_fw
>   any_errors_fatal: True
>   gather_facts: no
>   connection: local
>
>   vars:
> cli:
>   host: "{{ inventory_hostname }}"
>   username: ans
>   password: XXxxXXxXxX
> #  transport: cli
>   tasks:
> - asa_command:
> commands:
>   - show version
> provider: "{{ cli }}"
>   register: ver
>
> - debug: var=ver.stdout_lines
>
>
>
> This pretty much gets me what I was looking for although getting to this
> point drove me pretty crazy for the past few days. I'm new to Ansible but
> want to use it heavily in our managed services environment. My particular
> plan is to create reports with the output of this play.
>
>
> On Wednesday, March 7, 2018 at 1:15:39 PM UTC-5, Claudia de Luna wrote:
>>
>> Hi Otto,
>>
>> What version and model are you trying to gather facts from?
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/ansible-project/lnR8Ff5218o/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/c7a69746-9908-450f-b18f-56a81eb4e291%40googlegroups.
> com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAENRZgZTCdz-3%3DxxQtTvRcUfTjbBQ2yVVCm4DFjjqRsbaZs0fw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: ios_facts module unable to open shell [SOLVED]

2018-03-07 Thread Otto Nix
Hi Claudia,

Thanks for responding. I think the target hardware was the problem (I 
should have put that in the original post) , but not sure. It's a Cisco ASA 
5540 running 9.1(7)23. I just got this working using the asa_command module 
(which I didn't know existed). Is there a difference between Cisco IOS on 
an ASA? I have no idea, I'm the Linux guy, not the Network guy so...

Below is the playbook I used to solve my problem:
---
- hosts: ios_fw 
  any_errors_fatal: True 
  gather_facts: no
  connection: local 

  vars: 
cli: 
  host: "{{ inventory_hostname }}" 
  username: ans 
  password: XXxxXXxXxX 
#  transport: cli 
  tasks: 
- asa_command: 
commands: 
  - show version 
provider: "{{ cli }}" 
  register: ver 

- debug: var=ver.stdout_lines



This pretty much gets me what I was looking for although getting to this 
point drove me pretty crazy for the past few days. I'm new to Ansible but 
want to use it heavily in our managed services environment. My particular 
plan is to create reports with the output of this play.


On Wednesday, March 7, 2018 at 1:15:39 PM UTC-5, Claudia de Luna wrote:
>
> Hi Otto,
>
> What version and model are you trying to gather facts from?
>

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c7a69746-9908-450f-b18f-56a81eb4e291%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Copy module

2018-03-07 Thread senorsmile
I have had great success with the synchronize module as of Ansible 2.4. 

In my opinion, your use case sounds like reasoning to create a custom 
module. 

On Wednesday, March 7, 2018 at 11:03:36 AM UTC-8, Malcolm Hussain-Gambles 
wrote:
>
> After further investigation it appears there are a lot of serious short 
> comings using ansible directly to build an rpm.
> It looks like it's not a fault with ansible per say, just how I'm trying 
> to (ab)use it.
> The thought occurs about writing an ansible module to make rpms.
> Would there be wider interest in this?

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/890b14ee-c82b-40d9-b63e-6529f0cbe875%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Copy module

2018-03-07 Thread Malcolm Hussain-Gambles
After further investigation it appears there are a lot of serious short comings 
using ansible directly to build an rpm.
It looks like it's not a fault with ansible per say, just how I'm trying to 
(ab)use it.
The thought occurs about writing an ansible module to make rpms.
Would there be wider interest in this?

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ff31283d-33b2-47c9-9699-cf6a6fa52232%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: ios_facts module unable to open shell

2018-03-07 Thread Claudia de Luna
Hi Otto,

What version and model are you trying to gather facts from?

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ad74b670-99cf-49b8-a6a4-b1df21022257%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] inventory_dir is still present as a global variable in Ansible 2.4 ?

2018-03-07 Thread Matt Martz
Please see
http://docs.ansible.com/ansible/latest/porting_guide_2.4.html#inventory for
information about the change to inventory_dir

On Wed, Mar 7, 2018 at 5:24 AM, ishan jain  wrote:

> Hi All,
>
> I am trying to understand the changes with Ansible 2.4 that affects the
> usage of inventory_dir variable.
>
> Earlier i was using a static host file and in my playbooks, i was heavily
> relying on inventory_dir to load variable files which in turn was loading
> the target hosts. I understand the purpose of making the inventory_dir as a
> hostvar, what i did not understand is *how can i still access
> inventory_dir directly as a global variable in my playbooks* *?*
>
> To show what i mean, i created a little demo:
>
> *hosts.info *
> [locals]
> local1 localhost ansible_connection=local
> local2 localhost ansible_connection=local
>
>
>
> *varsFile.yaml*
> #This doesn't work anymore
> #moreVars: "{{ inventory_dir ~ 'moreVars.yaml' }}"
>
> #This also works
> #moreVars: "{{hostvars[groups.all.0].inventory_dir}}/moreVars.yaml"
>
> #This works and this is what i was using before 2.4
> moreVars: "{{inventory_dir}}/moreVars.yaml"
>
>
>
> *moreVars.yaml*
> #Prior to 2.4, this is how i defined target hosts. I understand this will
> not work anymore
> targetHosts: locals
>
> who: MORE_VARS
>
>
>
> *playbook.yaml*
> ---
> - hosts: locals
>   vars_files:
> - varsFile.yaml
> - "{{moreVars}}"
>
>   tasks:
>
>
>  - debug: var=who
>
>  - name: Accessing the inventory_dir as a host var
>debug: msg="Accessing inventory_dir as hostvar --
> {{hostvars[groups.all.0].inventory_dir}}"
>
>  - name: Accessing the inventory DIR directly
>debug: msg="Accessing inventory_dir directly -- {{inventory_dir}}"
>
>
>
>
> *output*
>
>
>
>
>
>
> *$ ansible --versionansible 2.4.3.0$ ansible-playbook playbook.yaml -i
> hosts.info PLAY [locals]
> ***TASK
> [Gathering Facts]
> **ok:
> [local1]ok: [local2]TASK [debug]
> ok:
> [local1] => {"who": "MORE_VARS"}ok: [local2] => {"who":
> "MORE_VARS"}TASK [Accessing the inventory_dir as a host var]
> ok:
> [local1] => {"msg": "Accessing inventory_dir as hostvar --
> /home/ij/temp"}ok: [local2] => {"msg": "Accessing inventory_dir as
> hostvar -- /home/ij/temp"}TASK [Accessing the inventory DIR directly]
> *ok:
> [local1] => {"msg": "Accessing inventory_dir directly --
> /home/ij/temp"}ok: [local2] => {"msg": "Accessing inventory_dir
> directly -- /home/ij/temp"}PLAY RECAP
> **local1
>: ok=4changed=0unreachable=0failed=0local2
>: ok=4changed=0unreachable=0failed=0*
>
>
> *So my questions:*
> *1) How is inventory_dir still available as global var ?*
> *2) Can i continue using it directly or i should
> use hostvars[groups.all.0].inventory_dir ?*
>
> --
> 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 post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/96846820-85b0-4aee-ac09-fb4062d9412f%40googlegroups.
> com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Matt Martz
@sivel
sivel.net

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 

Re: [ansible-project] expect module hangs

2018-03-07 Thread 'Daley Okuwa' via Ansible Project
Hi,

A big thanks you it worked

Very Much appreciated 

On Wednesday, March 7, 2018 at 12:34:11 PM UTC, Kai Stian Olstad wrote:

> On 07.03.2018 12:40, 'Daley Okuwa' via Ansible Project wrote: 
> > Hi, 
> > 
> > I have just done this manually on the switch and it worked 
> > 
> > User Access Verification 
> > Username: admin 
> > Password: 
> > POD2_C3560#copy running-config ftp: 
> > Address or name of remote host []? 10.241.11.237 
> > Destination filename [pod2_c3560-confg]? 
> > Writing pod2_c3560-confg !! 
> > 8063 bytes copied in 1.108 secs (7277 bytes/sec) 
> > POD2_C3560# 
>
> I think you forgot the exit at the end, so I included it. 
>
>- name: run show command via Telnet using the expect module 
>  expect: 
>command: telnet 10.101.250.12 
>responses: 
>  Username: admin 
>  Password: x 
>  POD2_C3560#: 
>- copy running-config ftp 
>- exit 
>  Address or name of remote host \[\]\?: 10.241.11.237 
>  Destination filename \[.*\]\?: '' 
>
>
> The '' is the same as just pressing enter. 
> I have escaped []? with backslash since they are character with meaning 
> in regex. 
> Since the prompt POD2_C3560# comes up two times this is a list with the 
> responses. 
>
>
>
> -- 
> Kai Stian Olstad 
>

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ae4e9cc1-2a89-40ad-b3f0-d25347cf1513%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] win_get_url always failing first time

2018-03-07 Thread Thijn Bukkems
Hey guys,

I run into an issue where my win_get_url always fails with the error "The 
remote server returned an error: (500) Internal Server Error.", 
"status_code": 500," the first time it is run each night. If I run the 
playbook again a couple minutes later the files download successfully. Does 
anyone have experience with this and can point me in the right direction 
figuring this out? The server is available, as the second attempt works 
flawlessly.

Thanks
Thijn


-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/57ab5c6d-4118-4559-9700-a67b0897d773%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] while running a playbook, new host is added with new group, so I want to update the running playbook cache to see the new group

2018-03-07 Thread Bar
hi All,

my playbook is asking for creating a new virtual machine.
the only thing I know about this virtual machine is its group name that 
will be added to the inventory host file later (I don't know its IP 
address).
while this virtual machine is been created and been added to the inventory 
file, my playbook is waiting for it to happen.
after this new virtual machine is been added, my playbook continues running.

I tried implementing this behavior with no success.
the last try is:

- name: wait for the new VM to be added to ansible_hosts inventory (1 hour 
timeout)
  wait_for:
  path: "{{ ansible_host_file }}"
  search_regex: "[GROUP_NAME]"
  timeout: 600
  delay: 10
  state: present
  delegate_to: localhost


- meta: refresh_inventory


the wait_for does not seem to wait at all, and meta does not seem to *update 
*the cache.


moreover, I tried to use "until" with only the meta module and it been ignored.

for example:


- meta: refresh_inventory

  until: groups[GROUP_NAME] is defined


Thank you

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5575d4fa-ccc5-44aa-85a5-e3ed7f4736dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] connection to multiple hosts with all different passwords

2018-03-07 Thread neccross9
Hi all,

I'm new to Ansible, so please excuse myl lack of knowledge 

I'm tryting to handle multiple hosts that need to execute some tasks being 
root.
While it's not a good idea to have all root-ssh-keys stored on one machine 
(the Ansible host), I want to connect to a box using a generic "ansible" 
user and then do a sudo (or su) to root
All hosts have different root-passwords. So I put some in an ansible-vault 
file and encrypted it.

Now I trie to build a playbook, that connects to a group of hosts - using 
the "ansible" user - sudo to root and e.g. 'apt-get upgrade'
According to the hostname, the matching root-password should be read from 
the ansible-vault file.
I know that I can specify the decrypt password with "--ask-vault-pass".
But how to tell the Playbook to look for a certain id, get the password and 
performe the sudo ?


regards

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/96ec2e60-8322-4d79-a9f0-c4c2d22c2d13%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Unable to run ansible playbook..

2018-03-07 Thread Kai Stian Olstad

On 07.03.2018 13:32, borseankush2...@gmail.com wrote:

I want to run a script via ansible playbook. The script contains
installation and uninstallation of some agents and If we run that
script, It requires some inputs like Yes or No or 1 or 2 like that...
So how to provide that inputs within ansible playbook. So that my
ansible playbook will run without any human interaction.


Check out the expect module.


--
Kai Stian Olstad

--
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/83226969d9ff86d9a022f7d19c545df3%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] expect module hangs

2018-03-07 Thread Kai Stian Olstad

On 07.03.2018 12:40, 'Daley Okuwa' via Ansible Project wrote:

Hi,

I have just done this manually on the switch and it worked

User Access Verification
Username: admin
Password:
POD2_C3560#copy running-config ftp:
Address or name of remote host []? 10.241.11.237
Destination filename [pod2_c3560-confg]?
Writing pod2_c3560-confg !!
8063 bytes copied in 1.108 secs (7277 bytes/sec)
POD2_C3560#


I think you forgot the exit at the end, so I included it.

  - name: run show command via Telnet using the expect module
expect:
  command: telnet 10.101.250.12
  responses:
Username: admin
Password: x
POD2_C3560#:
  - copy running-config ftp
  - exit
Address or name of remote host \[\]\?: 10.241.11.237
Destination filename \[.*\]\?: ''


The '' is the same as just pressing enter.
I have escaped []? with backslash since they are character with meaning 
in regex.
Since the prompt POD2_C3560# comes up two times this is a list with the 
responses.




--
Kai Stian Olstad

--
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/0acd2a8471c6fdc8bba9b7d66dd5aff6%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Unable to run ansible playbook..

2018-03-07 Thread borseankush2112
Hi Team,

I want to run a script via ansible playbook. The script contains installation 
and uninstallation of some agents and If we run that script, It requires some 
inputs like Yes or No or 1 or 2 like that...
So how to provide that inputs within ansible playbook. So that my ansible 
playbook will run without any human interaction. 

Thanks. 

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b2bbbca7-125e-4534-8227-5dfbf764873e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] expect module hangs

2018-03-07 Thread 'Daley Okuwa' via Ansible Project
Hi,

I have just done this manually on the switch and it worked

User Access Verification
Username: admin
Password:
POD2_C3560#copy running-config ftp:
Address or name of remote host []? 10.241.11.237
Destination filename [pod2_c3560-confg]?
Writing pod2_c3560-confg !!
8063 bytes copied in 1.108 secs (7277 bytes/sec)
POD2_C3560#

Thanks




On Tuesday, March 6, 2018 at 7:19:42 PM UTC, Kai Stian Olstad wrote:

> On Tuesday, 6 March 2018 18.15.12 CET 'Daley Okuwa' via Ansible Project 
> wrote: 
> > Hello 
> > 
> > I have a config to copy config to a tftp server 
> > but with the expect module 
> > it just hangs no error 
> > it logs it successful with telnet( I can see it in the logs) but does 
> not 
> > copy ( I have tested it manually with ftp) 
> > please tell me where I am going wrong 
> > 
> > --- 
> > - hosts: cisco 
> >   connection: local 
> >   gather_facts: yes 
> >   ignore_errors: yes 
> >   tasks: 
> > - name: run show command via Telnet using the expect module 
> >   expect: 
> >command: telnet 10.101.250.12 
> >responses: 
> >  Username: admin 
> >  Password: x 
> >  POD2_C3560#: 
> >command: copy running-config ftp 
> >responses: 
> >Address or name of remote host []?: 10.241.11.237 
> >Destination filename [pod2_c3560-confg]?: pod2_c3560-confg 
> >command: exit 
>
> It looks like you are trying with levels of responses, that is not 
> supported. 
> prompt bellow is also called question as in the documentation. 
>
> - expect: 
> command: tel... 
> responses: 
>   prompt-1: answer-1 
>   prompt-2: answer-2 
>   prompt-3: 
> - answer-3 
> - answer-4 
>   prompt-4: 
> - anser-5 
>
> When an prompt appears more than once you need a list of answers like 
> prompt-3 about, the first time it sees prompt-3 expect will respond with 
> answer-3, the nest time it sees prompt-3 it will respond with answer-4. 
> The prompt/question is regex, so all regex special character like ()[]? 
> need to be escaped if you have those character in that in the prompt. 
>
> It you don't get it working with this you need to provide the complete 
> output when you do this manually. 
>
> -- 
> Kai Stian Olstad 
>

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e5c05f45-a04f-4012-a784-7210c5588b12%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] expect module hangs

2018-03-07 Thread Kai Stian Olstad

On 07.03.2018 11:26, 'Daley Okuwa' via Ansible Project wrote:

thanks

when I run this I also get error message after amending the yaml script

---
- hosts: cisco
  connection: local
  gather_facts: yes
  ignore_errors: yes
  tasks:
- name: run show command via Telnet using the expect module
  expect:
   command: telnet 10.101.250.12
   responses:
 Username: admin
 Password: xx
   command: copy running-config ftp
 Address or name of remote host:
   -  10.241.11.237
 Destination filename pod2_c3560-confg:
   -  pod2_c3560-confg
 command: exit



You can only have one command: in expect.

If command is a prompt its not correctly indented.
And one prompt can only be listed once, the different responses is a 
list to that prompt.


If you would like more help you _need_ to provide the complete output 
when you do this task manually, without it this is futile.


--
Kai Stian Olstad

--
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/34a5dd72a432c7ac1d891689eddb68cf%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] inventory_dir is still present as a global variable in Ansible 2.4 ?

2018-03-07 Thread ishan jain
Hi All,

I am trying to understand the changes with Ansible 2.4 that affects the 
usage of inventory_dir variable.

Earlier i was using a static host file and in my playbooks, i was heavily 
relying on inventory_dir to load variable files which in turn was loading 
the target hosts. I understand the purpose of making the inventory_dir as a 
hostvar, what i did not understand is *how can i still access inventory_dir 
directly as a global variable in my playbooks* *?*

To show what i mean, i created a little demo:

*hosts.info*
[locals]
local1 localhost ansible_connection=local
local2 localhost ansible_connection=local



*varsFile.yaml*
#This doesn't work anymore
#moreVars: "{{ inventory_dir ~ 'moreVars.yaml' }}"

#This also works
#moreVars: "{{hostvars[groups.all.0].inventory_dir}}/moreVars.yaml"

#This works and this is what i was using before 2.4
moreVars: "{{inventory_dir}}/moreVars.yaml"



*moreVars.yaml*
#Prior to 2.4, this is how i defined target hosts. I understand this will 
not work anymore
targetHosts: locals

who: MORE_VARS



*playbook.yaml*
---
- hosts: locals
  vars_files:
- varsFile.yaml
- "{{moreVars}}"

  tasks:


 - debug: var=who

 - name: Accessing the inventory_dir as a host var
   debug: msg="Accessing inventory_dir as hostvar -- 
{{hostvars[groups.all.0].inventory_dir}}"

 - name: Accessing the inventory DIR directly
   debug: msg="Accessing inventory_dir directly -- {{inventory_dir}}"




*output*






*$ ansible --versionansible 2.4.3.0$ ansible-playbook playbook.yaml -i 
hosts.infoPLAY [locals] 
***TASK
 
[Gathering Facts] 
**ok:
 
[local1]ok: [local2]TASK [debug] 
ok:
 
[local1] => {"who": "MORE_VARS"}ok: [local2] => {"who": 
"MORE_VARS"}TASK [Accessing the inventory_dir as a host var] 
ok:
 
[local1] => {"msg": "Accessing inventory_dir as hostvar -- 
/home/ij/temp"}ok: [local2] => {"msg": "Accessing inventory_dir as 
hostvar -- /home/ij/temp"}TASK [Accessing the inventory DIR directly] 
*ok:
 
[local1] => {"msg": "Accessing inventory_dir directly -- 
/home/ij/temp"}ok: [local2] => {"msg": "Accessing inventory_dir 
directly -- /home/ij/temp"}PLAY RECAP 
**local1
  
   : ok=4changed=0unreachable=0failed=0local2  
   : ok=4changed=0unreachable=0failed=0*


*So my questions:*
*1) How is inventory_dir still available as global var ?*
*2) Can i continue using it directly or i should 
use hostvars[groups.all.0].inventory_dir ?*

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/96846820-85b0-4aee-ac09-fb4062d9412f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] expect module hangs

2018-03-07 Thread 'Daley Okuwa' via Ansible Project
thanks

when I run this I also get error message after amending the yaml script

---
- hosts: cisco
  connection: local
  gather_facts: yes
  ignore_errors: yes
  tasks:
- name: run show command via Telnet using the expect module
  expect:
   command: telnet 10.101.250.12
   responses:
 Username: admin
 Password: xx
   command: copy running-config ftp
 Address or name of remote host:
   -  10.241.11.237
 Destination filename pod2_c3560-confg:
   -  pod2_c3560-confg
 command: exit


Error message
ERROR! Syntax Error while loading YAML.

The error appears to have been in '/etc/ansible/backup-cisconew12-ine 14, 
column 40, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
   command: copy running-config ftp
 Address or name of remote host:
   ^ here
exception type: 
exception: mapping values are not allowed in this context
  in "", line 14, column 40




On Tuesday, March 6, 2018 at 7:19:42 PM UTC, Kai Stian Olstad wrote:

> On Tuesday, 6 March 2018 18.15.12 CET 'Daley Okuwa' via Ansible Project 
> wrote: 
> > Hello 
> > 
> > I have a config to copy config to a tftp server 
> > but with the expect module 
> > it just hangs no error 
> > it logs it successful with telnet( I can see it in the logs) but does 
> not 
> > copy ( I have tested it manually with ftp) 
> > please tell me where I am going wrong 
> > 
> > --- 
> > - hosts: cisco 
> >   connection: local 
> >   gather_facts: yes 
> >   ignore_errors: yes 
> >   tasks: 
> > - name: run show command via Telnet using the expect module 
> >   expect: 
> >command: telnet 10.101.250.12 
> >responses: 
> >  Username: admin 
> >  Password: x 
> >  POD2_C3560#: 
> >command: copy running-config ftp 
> >responses: 
> >Address or name of remote host []?: 10.241.11.237 
> >Destination filename [pod2_c3560-confg]?: pod2_c3560-confg 
> >command: exit 
>
> It looks like you are trying with levels of responses, that is not 
> supported. 
> prompt bellow is also called question as in the documentation. 
>
> - expect: 
> command: tel... 
> responses: 
>   prompt-1: answer-1 
>   prompt-2: answer-2 
>   prompt-3: 
> - answer-3 
> - answer-4 
>   prompt-4: 
> - anser-5 
>
> When an prompt appears more than once you need a list of answers like 
> prompt-3 about, the first time it sees prompt-3 expect will respond with 
> answer-3, the nest time it sees prompt-3 it will respond with answer-4. 
> The prompt/question is regex, so all regex special character like ()[]? 
> need to be escaped if you have those character in that in the prompt. 
>
> It you don't get it working with this you need to provide the complete 
> output when you do this manually. 
>
> -- 
> Kai Stian Olstad 
>

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/00960e7b-7081-4853-afed-dc5e5d64c220%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Error while using Yum install packages on existing rhel template on VMware

2018-03-07 Thread Shiva Gonela
Hi team, we are facing issues provisioning the rhel VM in Vmware 
environment using the existing template. 
here are list of tasks we are performing
-- provisioning the rhel Vm using existing template used vmware_guest module
-- wait for the VM to be reachable
-- set the environment variables
-- yum install httpd,gcc,php, mysql related packages
-- copy the files to /var/www on destination VM 
-- restart the httpd server

we are facing issues at yum install with repo issues.

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/9b7fdfa0-aa29-4ba1-96f2-feb68ed8ed1b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] pick the hostname dynamically from facts and match with inventory hostname and if matched then run the command

2018-03-07 Thread rraka1002
Thanks Kai.

On Wednesday, March 7, 2018 at 12:17:34 PM UTC+5:30, Kai Stian Olstad wrote:
>
> On Wednesday, 7 March 2018 06.31.27 CET rrak...@gmail.com  
> wrote: 
> > I'm looking for an idea to spill the hostname infromation geting from 
> facts 
> > and run the command if the matches the hostname provided in inventory. 
> > Saying that "myhostname" value should be picked & matched from inventory 
> > ones and get the IP of the hostname once matched to complete the command 
>
> A good start i this 
> https://docs.ansible.com/ansible/latest/playbooks_variables.html 
> 
>  
>
>
> > My Host inventory: 
> > 
> > test-host1 
> > test-host2 
>
> Try running ansible ad-hoc to see what facts you have available 
> ansible test-host1 -m setup 
> and/or 
> ansible localhost -m setup 
>
>
> > somecommand hostinfo=myhostname:IP_ADDRESS  
> > somecommand hostinfo=test-host1:xx.xx.xx.xx CIC01 
> > 
> > Exaplaination: 
> > 
> > somecommand = Static Value 
> > hostinfo = Static Value 
> > myhostname = Should be the same as taken from inventory 
>
> {{ inventory_hostname }} 
>
>
> > IP_ADDRESS = Should be the IP of Hostname taken from invetory 
>
> There are different once, check with the ad-hoc command above. 
> One is {{ ansible_default_ipv4.address }} 
>
>
> -- 
> Kai Stian Olstad 
>

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c0bef543-a91c-461f-9ac5-195fc3505ad1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.