[ansible-project] Error while deploying virtual machine from a template on VMware VCenter Server. Cannot complete login due to an incorrect user name or password.

2017-01-05 Thread Mick st john
ANSIBLE VERSION USED: 2.2.0


I am trying to deploy a virtual machine from a template that is already 
present on an ESX which is managed by a VCenter Server.

I'm getting the following error after the execution of my playbook:

"Cannot connect to x.x.x.x: [InvalidLoginFault]: Cannot complete login due 
to an incorrect user name or password."

Playbook is as follows:


- vsphere_guest:
vcenter_hostname: x.x.x.x
username: myuser
password: mypass
guest: newvm01
from_template: yes
template_src: sometemplate
cluster: MainCluster
resource_pool: "temppool"
validate_certs: False

When I ran the playbook in the verbose(-vvv) mode, the following things were 
observed:

--
fatal: [127.0.0.1]: FAILED! => {
"changed": false,
"failed": true,
"invocation": {
"module_args": {
"cluster": "MainCluster",
"esxi": {},
"force": false,
"from_template": true,
"guest": "newvm01",
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"power_on_after_clone": true,
"resource_pool": "temppool",
"snapshot_to_clone": null,
"state": "present",
"template_src": "sometemplate",
"username": "myuser}",
"validate_certs": false,
"vcenter_hostname": "x.x.x.x",
"vm_disk": {},
"vm_extra_config": {},
"vm_hardware": {},
"vm_hw_version": null,
"vm_nic": {},
"vmware_guest_facts": null
},
"module_name": "vsphere_guest"
},
"msg": "Cannot connect to x.x.x.x: [InvalidLoginFault]: Cannot complete 
login due to an incorrect user name or password."
}

PLAY RECAP *
127.0.0.1  : ok=0changed=0unreachable=0failed=1


The password value is not getting reflected for the json key password.




-- 
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/e2b7c420-311f-43fa-9cb8-1d6c12e62c36%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Human-readable and JSON output

2017-01-05 Thread Brian Coca
If you whitelist the syslog_json plugin it should do what you want. There
currently isn't a 'JSON to specific file' plugin, but using either plugin
as an example it should be easy to create.


--
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/CACVha7dL4niuSMgPGQ9GtuLneSc8x590u4AN8xOfD%2BR8UZ3KTQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Anyone using ansible to manage nexus and ios-xr devices?

2017-01-05 Thread Christer Hemgren
Hi

We have been doing nx-os (nx-api) of two new pods and most of ios-xe 
(netconf) for about 1.5 years now.  Still on Ansible 1.9.x.

Christer

Den tisdag 20 september 2016 kl. 04:50:26 UTC+2 skrev Peter Sprygada:
>
> HI Ryan,
>
> There are a number of organizations that are currently using both nxos and 
> iosxr modules in production today.  We went through a fairly significant 
> refactor for 2.2 which means we are presently tracking down lots of bugs 
> but the code base is stabilizing quickly and is definitely the preferred 
> train to be on.  Of course goes without saying, do you own due diligence.  
> Happy to help out where we can.
>
> Peter
>
> On Mon, Sep 19, 2016 at 4:39 PM, Ryan Jones  > wrote:
>
>> Thanks. I still haven't started working on this project yet but I was 
>> curious as how good the support was.
>>
>> On Friday, September 16, 2016 at 1:04:00 PM UTC-4, Steven Carter wrote:
>>>
>>> I am trying to use the NXOS modules, but they seem to be in a state of 
>>> Flux.  The NXOS modules for Ansible 2.1 are lacking, and I am having having 
>>> trouble getting the modules for 2.2 working (posted the problem just a bit 
>>> ago).
>>>
>>> Thanks,
>>>
>>> Steven.
>>>
>>> On Thursday, September 15, 2016 at 3:43:26 PM UTC-4, Ryan Jones wrote:

 I'm trying to put together a poc. The issue is i have no idea where to 
 start. I'm somewhat familiar with ansible for servers but I'd like to 
 start 
 managing my network infra with ansible. O e of the questions i have is how 
 so you test a change is valid? And how to automate these tests. I'd like 
 to 
 get to the point where a change is reviewed then automatically tested and 
 deployed. 
>>>
>>> -- 
>> 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-proje...@googlegroups.com .
>> To post to this group, send email to ansible...@googlegroups.com 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/2548bc6d-357f-4799-90ed-554d91058f22%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/a9716012-fe95-4ffa-9ca3-f982ec8d89fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible with Cisco IOS and two steps authentication (Tacacs)

2017-01-05 Thread Christer Hemgren
Hi Uni

You can use your tacacs to not need "enable 7" as I do not think the module 
support it.

Meaning when user x enter only standard enable and authorize by tacacs 
return enable privilage level 7.
See 
http://www.cisco.com/c/en/us/support/docs/security-vpn/remote-authentication-dial-user-service-radius/13860-PRIV.html

Christer  


Den onsdag 9 mars 2016 kl. 11:46:01 UTC+1 skrev Uni:
>
> Would that work when I send "enable 7" instead of "enable" ? 
> How do I make Ansible use "enable 7" for authoirzation? 
>
> On Tuesday, 8 March 2016 19:32:20 UTC-5, pspr...@ansible.com wrote:
>>
>> You can use the following arguments to any of the IOS modules:
>>
>> authorize: yes 
>> auth_pass: >
>>
>>
>> On Tuesday, March 8, 2016 at 10:59:30 AM UTC-5, Uni wrote:
>>>
>>> Hi guys
>>>
>>> I am totally new to Ansible. Could anyone of you please point me to an 
>>> example on how to use Ansible with two steps authentication? Our network 
>>> devices access in controlled by Tacas+ and we have to authenticate to get 
>>> access and then use "enable x" to get to the access level that we need. 
>>> This command also requires authentication How is this handled in Ansible?
>>>
>>

-- 
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/fb154f6b-06e2-48c5-87e2-6ae2442d62ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] How to use ignore_errors and include statement together?

2017-01-05 Thread Brian Coca
that will only work on dynamic includes

- include: tasks/{{ worker_type }}.yml
  static: no
  ignore_errors: yes


--
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/CACVha7ca5ZMBqsJdtS9ivGKF5er0TDvb8S_HApWS8oNXAhDN4w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Automatically connecting as different user on later runs after 'root' is disabled

2017-01-05 Thread Brian Coca
Ansible itself avoids dealing with state, but it can easily use saved state
as an input or output current state in a way you can save. You need to
either modify the play to deal with finding out the state dynamically or
you save state and pass it in.

As to which one is 'cleanest' ... that is very subjective.


--
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/CACVha7ebO6u8MbH2t09j3Fx%2B0%3DRapKf7KYkMSWC-W9T6WOawFA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Automatically connecting as different user on later runs after 'root' is disabled

2017-01-05 Thread Greg Bell

Thanks for the thoughts Brian.

> You could have the first task attempt to 'connect as root and set
> the other user', ignore their failure and continue with rest of
> play with correct credentials

This is a new idea to me.  Obviously some smell around ignoring failures.


> You could skip the 'as root' tasks depending on a passed var

Requires operator knowledge of state.


> Variation on the above, have the play update host_vars for that host
> with needs_root=False and have needs_root=True in group_vars/all.yml
> after updating the machine to not need root.

This is interesting.  In effect, I'm keeping knowledge of state on the 
local machine.  Downsides might be - others operators don't have my 
machine's state knowledge, I've built a non-obvious state mechanism, 
and some machines in a group may fail, thus the state of the group is 
not necessarily accurate.



> Another variation, add the host to 'doesnt_need_root' group in play

Interesting idea.  Then the inventory sort of becomes a text-based
database, manipulated by plays.  Yuck.

Which of these seems cleanest to you?  The automatic ones all feel
like complicated mechanisms built on top of Ansible that sort  of go 
against the ideology of Ansible.



~gb

--
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/5e8305a8-befc-91b0-263f-9c090c2579ef%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: wait_for_ip_address timeout in vmware_guest module

2017-01-05 Thread Neil Watson

FYI:
https://github.com/ansible/ansible/pull/19947

-- 
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/2421fb90-5655-4b69-ae6f-50453094a11d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Automatically connecting as different user on later runs after 'root' is disabled

2017-01-05 Thread Brian Coca
several ways:

You could have the first task attempt to 'connect as root and set the other
user', ignore their failure and continue with rest of play with correct
credentials

You could skip the 'as root' tasks depending on a passed var

Variation on the above, have the play update host_vars for that host with
needs_root=False and have needs_root=True in group_vars/all.yml after
updating the machine to not need root.

Another variation, add the host to 'doesnt_need_root' group in play

etc.


--
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/CACVha7fML8q%3DppfN9w%2BkjLAAejH26m7SXzsooBrRN5gAwcLxFg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Ansible stdout_lines writes as list syntax [u'text1',u'text2'] instead of multiline?

2017-01-05 Thread Brian Coca
Just use stdout ... which is a multiline string, stdout_lines is a split of
this for people to use each line in a list.


--
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/CACVha7fh62DNjRU5OQOXnR_W6601HWNesGFt7i53%2BNpxaSWQWA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Using lookup plugin within include_vars to build file name

2017-01-05 Thread Sam Sen
Running Ansible 2.1.1

I want to dynamically build the variable name for a file I wish to load 
using "include_vars." it doesn't work using the lookup plugin but the 
lookup plugin itself does work when I use the "debug" method.


- name: load var file
  include_vars: "{{ lookup('ini','environment section=environment_info 
file=/etc/abc123.conf') }}.yml"

Error:


TASK [sam : load var file] 
*
task path: /home/ssen/ansible_ops/roles/sam/tasks/main.yml:5
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", 
line 124, in run
res = self._execute()
  File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", 
line 448, in _execute
result = self._handler.run(task_vars=variables)
  File 
"/usr/lib/python2.7/site-packages/ansible/plugins/action/include_vars.py", 
line 39, in run
source = self._loader.path_dwim_relative(self._task._role._role_path, 
'vars', source)
  File "/usr/lib/python2.7/site-packages/ansible/parsing/dataloader.py", 
line 236, in path_dwim_relative
if source.startswith('~') or source.startswith('/'):
AttributeError: 'NoneType' object has no attribute 'startswith'


fatal: [localhost]: FAILED! => {"failed": true, "msg": "Unexpected failure 
during module execution.", "stdout": ""}








-- 
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/b75943d5-6c47-4075-8dcb-4ddea5bae25f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Iterate through user input data

2017-01-05 Thread Brian Coca
The `pause` module can prompt and use the responses for a more
'interactive' play. So for example, you can use `stat` to check if the
directory exists and `pause` to ask what to do next.


--
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/CACVha7d4r7OArExyB45aJADt4QwFVAAOcUE2pswctqJ4fMfZZw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] wait_for_ip_address timeout in vmware_guest module

2017-01-05 Thread Neil Watson
Greetings,

I'm seeing evidence that the vmware_guest module does not wait long enough 
to get the guest's new IP. Is there a way to increase the wait time?

TASK [provision_vm_and_set_ip : Create VM from template] 
***
changed: [vsphere_dcos1_bootstrap] => {"changed": true, "failed": false, 
"instance": {"hw_eth13": {"addresstype": "assigned", "ipaddresses": 
["fe80::250:56ff:feab:83d6"], "label": "Network adapter 1", "macaddress": 
"00:50:56:ab:83:d6", "macaddress_dash": "00-50-56-ab-83-d6", "summary": "VM 
Network"}, "hw_guest_full_name": "CentOS 4/5/6/7 (64-bit)", "hw_guest_id": 
"centos64Guest", "hw_interfaces": ["eth13"], "hw_memtotal_mb": 2048, 
"hw_name": "dcos1_bootstrap", "hw_power_status": "poweredOn", 
"hw_processor_count": 1, "hw_product_uuid": 
"422bbd74-90a6-a0c2-7aee-159722b8884c", "ipv4": null, "ipv6": 
"fe80::250:56ff:feab:83d6", "module_hw": true}}
changed: [vsphere_dcos1_master2] => {"changed": true, "failed": false, 
"instance": {"hw_eth13": {"addresstype": "assigned", "ipaddresses": 
["fe80::250:56ff:feab:5c0b"], "label": "Network adapter 1", "macaddress": 
"00:50:56:ab:5c:0b", "macaddress_dash": "00-50-56-ab-5c-0b", "summary": "VM 
Network"}, "hw_guest_full_name": "CentOS 4/5/6/7 (64-bit)", "hw_guest_id": 
"centos64Guest", "hw_interfaces": ["eth13"], "hw_memtotal_mb": 2048, 
"hw_name": "dcos1_master2", "hw_power_status": "poweredOn", 
"hw_processor_count": 1, "hw_product_uuid": 
"422b9843-43c5-b0ae-1172-ecb333bff0bb", "ipv4": null, "ipv6": 
"fe80::250:56ff:feab:5c0b", "module_hw": true}}
changed: [vsphere_dcos1_master1] => {"changed": true, "failed": false, 
"instance": {"hw_eth13": {"addresstype": "assigned", "ipaddresses": 
["10.120.8.215", "fe80::250:56ff:feab:464f"], "label": "Network adapter 1", 
"macaddress": "00:50:56:ab:46:4f", "macaddress_dash": "00-50-56-ab-46-4f", 
"summary": "VM Network"}, "hw_guest_full_name": "CentOS 4/5/6/7 (64-bit)", 
"hw_guest_id": "centos64Guest", "hw_interfaces": ["eth13"], 
"hw_memtotal_mb": 2048, "hw_name": "dcos1_master1", "hw_power_status": 
"poweredOn", "hw_processor_count": 1, "hw_product_uuid": 
"422bd28d-35d6-349f-9424-81fc957d81cc", "ipv4": "10.120.8.215", "ipv6": 
"fe80::250:56ff:feab:464f", "module_hw": true}}
changed: [vsphere_dcos1_master3] => {"changed": true, "failed": false, 
"instance": {"hw_eth13": {"addresstype": "assigned", "ipaddresses": 
["10.120.8.214", "fe80::250:56ff:feab:506e"], "label": "Network adapter 1", 
"macaddress": "00:50:56:ab:50:6e", "macaddress_dash": "00-50-56-ab-50-6e", 
"summary": "VM Network"}, "hw_guest_full_name": "CentOS 4/5/6/7 (64-bit)", 
"hw_guest_id": "centos64Guest", "hw_interfaces": ["eth13"], 
"hw_memtotal_mb": 2048, "hw_name": "dcos1_master3", "hw_power_status": 
"poweredOn", "hw_processor_count": 1, "hw_product_uuid": 
"422b853f-359e-a2b7-5e66-4f4e1536df5b", "ipv4": "10.120.8.214", "ipv6": 
"fe80::250:56ff:feab:506e", "module_hw": true}}

TASK [provision_vm_and_set_ip : set_fact] 
**
ok: [vsphere_dcos1_bootstrap] => {"ansible_facts": {"new_vm": ""}, 
"changed": false}
ok: [vsphere_dcos1_master1] => {"ansible_facts": {"new_vm": 
"10.120.8.215"}, "changed": false}
ok: [vsphere_dcos1_master2] => {"ansible_facts": {"new_vm": ""}, "changed": 
false}
ok: [vsphere_dcos1_master3] => {"ansible_facts": {"new_vm": 
"10.120.8.214"}, "changed": false}

  - name: Create VM from template   
 
vmware_guest:   
 
  validate_certs: False 
 
  hostname: "{{ vcenter_hostname }}"   
  
  username: "{{ vcenter_user }}"   
  
  password: "{{ vcenter_pass }}"   
  
  name: "{{ vm_name }}" 
 
  state:poweredon   
 
  template: "{{ vmtemplate }}" 
  
  folder:   "{{ folder }}" 
  
  disk: 
 
- size_gb: 20   
 
  type: thin   
  
  datastore: "{{ datastore }}" 
  
  nic: 
  
- type: vmxnet3 
 
  network: "{{ network }}" 
  
  datacenter: "{{ esx_datacenter }}"   
  
  wait_for_ip_address: True 
 
register: newvm 

Re: [ansible-project] concatenate a value with another variable in default filter

2017-01-05 Thread Nicolas G
Got it Matt , that makes sense.

Thanks .

On Thursday, January 5, 2017 at 10:46:00 AM UTC-5, Matt Martz wrote:
>
> Your general approach is pretty much correct in your last example:
>
> - hosts: "{{ hosts | default('bid-'+ dc) }}"
>
> Although jinja2 recommends using a `~` instead of `+` for string 
> concatenation, although both will work.
>
> However, the real problem is with your variable.  You have created the 
> `dc` variable in your inventory, which means that it is scoped to the hosts 
> within that group.  Because you are using the `dc` variable in your `hosts` 
> declaration, no hosts have been targeted, and additionally, the `dc` 
> variable is per host, not global.
>
> As such, you cannot use the `dc` variable in a hosts declaration due to 
> variable scoping, and the `dc` variable not being defined at that point.
>
> The only real place to define a variable that can be used in the `hosts` 
> declaration is via the command line via -e/--extra-vars
>
> On Thu, Jan 5, 2017 at 8:10 AM, Nicolas G  > wrote:
>
>> I have the bellow Ansible inventory :
>>
>> [web:children]
>> web-eu-west
>> web-us-east
>> [eu:vars]
>> dc=eu-west
>> [eu:children]
>> web-eu-west
>> [us:vars]
>> dc=us-east
>> [us:children]
>> web-us-east
>>
>>
>> The bellow is working fine in my playbook  :
>> -- hosts: "{{  hosts | default('web') }}"
>>
>>
>> Unfortunately we have a case now where we need to combine the *dc *variable 
>> in the default filter , I'm trying the bellow two combinations with errors :
>>
>> - hosts: "{{ hosts | default('web-'dc) }}"
>>
>>> ERROR! template error while templating string: expected token ',', got 
>>> 'dc'. String: {{ hosts | default('web-'dc) }}
>>
>>
>> - hosts: "{{ hosts | default('bid-'+ dc) }}"
>>
>>> ERROR! the field 'hosts' has an invalid value, which appears to include 
>>> a variable that is undefined. The error was: 'dc' is undefined
>>
>>
>> What is the right way to concatenate a value and a var using the default 
>> filter ?
>>
>> -- 
>> 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-proje...@googlegroups.com .
>> To post to this group, send email to ansible...@googlegroups.com 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/1a96a93f-11a3-485a-be73-58beeb046c6f%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 
https://groups.google.com/d/msgid/ansible-project/f7b300ba-f154-44a1-80c9-a459e4ea4876%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Initializing "List" with dynamic values through "with_items" is not working .

2017-01-05 Thread Brian Coca
In this case you are setting path to each item path on every loop, not
appending as set_fact is not capable of this.

What you want is a map:

set_fact: path="{{result.files|map(attribute='path')|list)}"



--
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/CACVha7d_xvVsD-MjSrNA%3DA5_wrUiPVo22H5yb2DZ8DJ%2BxiSDPw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Initializing "List" with dynamic values through "with_items" is not working .

2017-01-05 Thread Ritesh Sharma
Hi Guys , 

i am attempting to initialise list (array) with set_fact method with some 
dynamic values through with_items ; but getting failure for same ; it seems 
like my list is acting as a normal variable and printing the last value 
assigned to it. 

here's the playbook for same .


---
- hosts: wallet
  tasks:
- name: Verifying existence of stat directory
  file: path=/tmp/ansibleTest  state=directory

- name: Identify current logging directory 
  find: paths="/tmp/ansibleTest/perf_output" file_type="directory" 
age="-2m" recurse="yes" age_stamp="mtime"
  register: result

- debug: var=result

- set_fact: path="{{item.path}}"
  with_items: "{{result.files}}"   

   - debug: var=path 

path is acting as a normal variable and priniting last value assigned to it 
through - with_items: "{{result.files}}" ; I am expecting list of values 
contained by result.files[]

Kindly, reply what exactly i am doing incorrectly.


Kind Regards,

Ritesh .  


 

-- 
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/208584a9-7a48-4e85-9808-86f3bf096f8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] how to synchronize files or Dir between different remote hosts?

2017-01-05 Thread 张利高
how to synchronize files or Dir between different remote hosts? 

if there are 2 hosts: s1 and s2, and ansible running at s3,
how to synchronize dirs on s1 and s2?

-- 
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/e7648afd-2ed0-4756-9734-9f322f795bca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] digital_ocean module and host_vars

2017-01-05 Thread Jerry Steele
Hi All,

It looks like I've stumbled across a bug with the digital_ocean module.

I've been following the digital ocean tutorial here 
,
 
but I want to parameterise as much as possible. I'm building a role, and 
this is the main tasks.yml:

- hosts: digitalocean
  vars:
- zonomi_api_key: 
- zonomi_url: http://zonomi.com/app/dns/dyndns.jsp
- do_url: 
- do_domain: 
  tasks:

- name: Add droplet
  digital_ocean: >
state=present
command=droplet
name={{ item.key }}
size_id=512mb
region_id=ams2
image_id={{ item.value.image_id }}
ssh_key_ids={{ my_ssh_key.ssh_key.id }}
unique_name=yes
  with_dict: "{{ droplets_up }}"
  register: my_droplet


- debug:
msg: {{ my_droplet.droplet.ip_address }

 The host_vars are elsewhere, but I don't believe they're important in this 
context - the droplet gets created as expected.

However, I get the following error about the "ip_address" var:

fatal: [localhost]: FAILED! => {"failed": true, "msg": "the field 'args' 
has an invalid value, which appears to include a variable that is 
undefined. The error was: 'dict object' has no attribute 'id'\n\nThe error 
appears to have been in '/my/path/digitalocean.yml': line 33, column 7, but 
may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe 
offending line appears to be:\n\nmsg: Droplet details are {{ 
my_droplet }}\n- debug:\n  ^ here\n"}

The official docs 
 appear to 
suggest that this should work, and if I print debug output of "my_droplet" 
on its own, I get a dump of the variable with all its data (I won't reprint 
it unless it's required as it would take a while to go through and 
obfuscate any sensitive data). I would like the ability to pick out certain 
parts of the var (in this instance, I need the IP in order to publish it to 
my DNS server..

Thanks

Jerry


-- 
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/7a88bf2d-03e1-479e-aab2-6bd03a19317d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] concatenate a value with another variable in default filter

2017-01-05 Thread Matt Martz
Your general approach is pretty much correct in your last example:

- hosts: "{{ hosts | default('bid-'+ dc) }}"

Although jinja2 recommends using a `~` instead of `+` for string
concatenation, although both will work.

However, the real problem is with your variable.  You have created the `dc`
variable in your inventory, which means that it is scoped to the hosts
within that group.  Because you are using the `dc` variable in your `hosts`
declaration, no hosts have been targeted, and additionally, the `dc`
variable is per host, not global.

As such, you cannot use the `dc` variable in a hosts declaration due to
variable scoping, and the `dc` variable not being defined at that point.

The only real place to define a variable that can be used in the `hosts`
declaration is via the command line via -e/--extra-vars

On Thu, Jan 5, 2017 at 8:10 AM, Nicolas G  wrote:

> I have the bellow Ansible inventory :
>
> [web:children]
> web-eu-west
> web-us-east
> [eu:vars]
> dc=eu-west
> [eu:children]
> web-eu-west
> [us:vars]
> dc=us-east
> [us:children]
> web-us-east
>
>
> The bellow is working fine in my playbook  :
> -- hosts: "{{  hosts | default('web') }}"
>
>
> Unfortunately we have a case now where we need to combine the *dc *variable
> in the default filter , I'm trying the bellow two combinations with errors :
>
> - hosts: "{{ hosts | default('web-'dc) }}"
>
>> ERROR! template error while templating string: expected token ',', got
>> 'dc'. String: {{ hosts | default('web-'dc) }}
>
>
> - hosts: "{{ hosts | default('bid-'+ dc) }}"
>
>> ERROR! the field 'hosts' has an invalid value, which appears to include a
>> variable that is undefined. The error was: 'dc' is undefined
>
>
> What is the right way to concatenate a value and a var using the default
> filter ?
>
> --
> 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/1a96a93f-11a3-485a-be73-58beeb046c6f%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 
https://groups.google.com/d/msgid/ansible-project/CAD8N0v_4H%3DPPtyCypjg2YVy1DxQwLAjh6Zs23xvRj87mOSq4zg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] concatenate a value with another variable in default filter

2017-01-05 Thread Johannes Kastl
On 05.01.17 15:10 Nicolas G wrote:
> - hosts: "{{ hosts | default('web-'dc) }}"

Try this:

- hosts: "{{ hosts | default([ [ 'web-', dc ] | join ] ) }}"
or
- hosts: "{{ hosts | default([ 'web-', dc ] | join ) }}"

Not sure if you need two sets of square brackets.

Johannes

-- 
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/914a07d6-492f-bab0-86f9-a1a254a883ef%40ojkastl.de.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: OpenPGP digital signature


[ansible-project] Re: regex_replace flags

2017-01-05 Thread Dick Visser
I just found a nice way of supplying re.sub compile flags to regex_replace.

https://docs.python.org/2/library/re.html, at '(?iLmsux)'


So for instance, this would not work:

regex_replace('.*([a-z0-9]{40}).*', '\\1')

I just found out that I would need the re.S flag (make '.' match any char).

You can supply that as part of the regex:

regex_replace('(?s).*([a-z0-9]{40}).*', '\\1')


I would preferred this over hard coded flag options in Ansible.


Dick


On 5 January 2017 at 12:12, Dick Visser  wrote:
> Hi
>
> One of my plays tries to do a regex_replace on the returned content of
> the uri module, which is HTML with new lines in it.
> This seems to fail as from the debug output I can see that
> regex_replace doesn't do multiline matching.
>
> I see that there is basically only one flag for re.sub in regex_replace:
>
> https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/filter/core.py#L137-L140
>
> For my regex to work, I would need both the re.MULTILINE and re.DOTALL
> flags to be set for re.sub.
>
> Instead of hard coding one or two flags as arguments, wouldn't it make
> sense to have the filter accept an argument of the raw flags?
>
> This would make things much more flexible (and powerful!).
>
>
>
> --
> Dick Visser
> Sr. System & Network Engineer
> GÉANT
>
> Want to join us? We're hiring: https://www.geant.org/jobs



-- 
Dick Visser
Sr. System & Network Engineer
GÉANT

Want to join us? We're hiring: http://www.geant.org/jobs

-- 
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/CAEQQDN%3Dq9e2F%3DyBpVKAiUbd_5Tm0EoFeg%2BYBPfV%3D2%2BtrWLPy3Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] regex_replace flags

2017-01-05 Thread Dick Visser
Hi

One of my plays tries to do a regex_replace on the returned content of
the uri module, which is HTML with new lines in it.
This seems to fail as from the debug output I can see that
regex_replace doesn't do multiline matching.

I see that there is basically only one flag for re.sub in regex_replace:

https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/filter/core.py#L137-L140

For my regex to work, I would need both the re.MULTILINE and re.DOTALL
flags to be set for re.sub.

Instead of hard coding one or two flags as arguments, wouldn't it make
sense to have the filter accept an argument of the raw flags?

This would make things much more flexible (and powerful!).



-- 
Dick Visser
Sr. System & Network Engineer
GÉANT

Want to join us? We're hiring: https://www.geant.org/jobs

-- 
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/CAEQQDNkLRK%2BuasX7JRRjbGN6kv83%2B9pQ1%2Bi5Lm0pd00teHDZjg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Help with package installation playbook

2017-01-05 Thread Cosimo Streppone
On 04. jan. 2017 19:42, Andreas Olsson wrote:
> ons 2017-01-04 klockan 13:25 +0100 skrev Cosimo Streppone:
>
>> what is the "use" option?
> 
> See https://docs.ansible.com/ansible/package_module.html

Thanks all,

-- 
Cosimo

-- 
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/31cd9ea4-01a4-3971-6b97-0f294f694501%40streppone.it.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Install EXE on Windows

2017-01-05 Thread Ansible_Red
Hi Hawkesworth,

It would be great if you could show me something related to this with the 
RAW module.

Kr,

Op woensdag 4 januari 2017 20:50:28 UTC+1 schreef J Hawkesworth:
>
> Sounds like the application you are trying to install contains a dcom 
> component. You might need to find a copy of dcomperm.exe and use it to 
> grant launch and activation to the user you are running as, or possibly to 
> the user that the dcom component is configured to run as.
>
> I can dig out some examples of using dcomperm.exe to do something similar 
> if you need.  Check the documentation for the exe to find out what dcom 
> permissions it needs.
>
> My guess would be that the app is expecting to run as an interactive user, 
> which you wont be running as under winrm, so you'll probably need to grant 
> explicit dcom permissions before attempting to install.
>
> I can dig out some examples of using dcomperm.exe via raw module if you 
> need.
>
> Hope this helps,
>
> Jon
>
>

-- 
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/44a3593d-0405-432b-86a2-524d8ff62f3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.