Re: [ansible-project] Re: vsphere wait for vm powered off

2018-04-13 Thread Zeljko Dokman
Hi, thank you for your replay

Do you know is it possible to list all undocumented parameters of a module 
and its states?

Regards


On Thursday, April 12, 2018 at 5:09:05 PM UTC+2, Kai Stian Olstad wrote:
>
> On 12.04.2018 14:11, Zeljko Dokman wrote: 
> > Hi, 
> > thank you for the info. 
> > one more question, for vsphere_guest module, how to know that "state" 
> > parameter should be referenced as 
> > "vm_state.ansible_facts.hw_power_status", this part a have not find in 
> > the 
> > documentation.? how is this contracted for all other parameters for 
> > particular module? 
>
> Some module has this documented, but most of them don't unfortunately. 
> So you are left with finding it yourself. 
>
> To do that you run the module with "register: ..." directive and print 
> the content of the variable. 
> The content you print like this 
>
>- debug: var=vm_state 
>
>
> -- 
> 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/fa0d51bb-527b-452b-9376-0514bce263aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: vsphere wait for vm powered off

2018-04-12 Thread Zeljko Dokman
Hi,
thank you for the info.
one more question, for vsphere_guest module, how to know that "state" 
parameter should be referenced as 
"vm_state.ansible_facts.hw_power_status", this part a have not find in the 
documentation.? how is this contracted for all other parameters for 
particular module?

Best regards


On Wednesday, April 11, 2018 at 7:09:07 PM UTC+2, Kai Stian Olstad wrote:
>
> On Wednesday, 11 April 2018 11.05.42 CEST Zeljko Dokman wrote: 
> > Hi, thank you, your suggestion works. 
> > I am wondering are this options documented some where? or how can I list 
> > this option for a module? 
> > Ansible documentation is not covering all this options or I haven't been 
> > able to find it.   
>
> The directives one the same level as vsphere_guest is not part of the 
> module they are part of the task. 
> The directive you can use and where is documented here 
>
> https://docs.ansible.com/ansible/latest/reference_appendices/playbooks_keywords.html
>  
>
> The documentation for until you'll find here 
>
> https://docs.ansible.com/ansible/latest/user_guide/playbooks_loops.html#do-until-loops
>  
>
>
> -- 
> 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/378f1896-e51f-4f1a-a4f2-9aa56ca3ffe9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: vsphere wait for vm powered off

2018-04-11 Thread Zeljko Dokman
Hi, thank you, your suggestion works. 
I am wondering are this options documented some where? or how can I list 
this option for a module?
Ansible documentation is not covering all this options or I haven't been 
able to find it.  

here is a working code 
   - name: Wait till {{ target }} is powered off
 vsphere_guest:
  vcenter_hostname="{{ vcenter_server }}"
  username=ansible@local.domain
  password="{{ vc_passwd }}"
  guest="{{ ansible_hostname }}"
  validate_certs=False
  vmware_guest_facts=yes
 register: vm_state
 until: vm_state.ansible_facts.hw_power_status == 'POWERED OFF'
 retries: 10
 delay: 5
 delegate_to: localhost

  
Best regards


On Tuesday, April 10, 2018 at 9:09:42 PM UTC+2, robert sanders wrote:
>
> change result to vm_state if youre using vsphere_guest
>
> register: vm_state
>   until: vm_state.ansible_facts.hw_power_status == 'POWERED OFF'
>   retries: 10
>   delay: 5
>
> On Wednesday, April 4, 2018 at 9:34:32 AM UTC-4, Zeljko Dokman wrote:
>>
>> Hi, I am trying to use this code to check VM power state and its failing 
>> for me with this error..
>>
>>  "msg": "The conditional check 'result.hw_power_status == \"POWERED 
>> OFF\"' failed. The error was: error while evaluating conditional 
>> (result.hw_power_status == \"POWERED OFF\"): 'dict object' has no attribute 
>> 'hw_power_status'"
>>
>> My playbook..
>> Enter code here...   - name: Wait till {{ target }} is powered off
>>  vsphere_guest:
>>   vcenter_hostname="{{ vcenter_server }}"
>>   username=ansible@mbu.local
>>   password="{{ vc_passwd }}"
>>   guest=mbu-zabbix-ccp
>>   validate_certs=False
>>   vmware_guest_facts=yes
>>  register: result
>>  until: result.hw_power_status == "POWERED OFF"
>>  retries: 10
>>  delay: 5
>>
>> i tried with 
>> result.hw_power_status == "POWERED OFF"
>> and
>> result.ansible_facts.hw_power_status == "POWERED OFF"
>>
>> both fail with a same error..
>>
>> 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/bc04c776-0dff-4ab4-a1ab-c9021ff1e4ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: vsphere wait for vm powered off

2018-04-04 Thread Zeljko Dokman
Hi, I am trying to use this code to check VM power state and its failing 
for me with this error..

 "msg": "The conditional check 'result.hw_power_status == \"POWERED OFF\"' 
failed. The error was: error while evaluating conditional 
(result.hw_power_status == \"POWERED OFF\"): 'dict object' has no attribute 
'hw_power_status'"

My playbook..
Enter code here...   - name: Wait till {{ target }} is powered off
 vsphere_guest:
  vcenter_hostname="{{ vcenter_server }}"
  username=ansible@mbu.local
  password="{{ vc_passwd }}"
  guest=mbu-zabbix-ccp
  validate_certs=False
  vmware_guest_facts=yes
 register: result
 until: result.hw_power_status == "POWERED OFF"
 retries: 10
 delay: 5

i tried with 
result.hw_power_status == "POWERED OFF"
and
result.ansible_facts.hw_power_status == "POWERED OFF"

both fail with a same error..

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/17584e0c-9748-486c-a02f-92efb0b420dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Add new user and add to existing group

2018-03-19 Thread Zeljko Dokman

>
>
> groups is a reserved variable name in Ansible, groups contain all the 
> groups in the inventory. 
>
> http://docs.ansible.com/ansible/latest/playbooks_variables.html#magic-variables-and-how-to-access-information-about-other-hosts
>  
>
> -- 
> Kai Stian Olstad 
>


So simple solution but it did not cross my mind,
Thank you for your help.

Best 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/99aa3bcb-aca5-4891-8995-dc23334e029a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Add new user and add to existing group

2018-03-19 Thread Zeljko Dokman
Hi,

Can some one help me with my playbook for adding new user and adding that 
user to existing groups...

Playbook
- hosts: "{{ target }}"
  become: yes
  become_user: root
  become_method: sudo
  gather_facts: no

  tasks:
- name: User add "{{ user }}"
  user: name="{{ user }}" comment="{{ comment }}" uid="{{ uid }}" 
groups="{{  groups }}"
  notify:
- Chage added user

  handlers:
- name: Chage added user
  shell: chage -M 9 "{{ user }}"


My command...
ansible-playbook user_add_and_to_group.yaml -K -e 
"target=egcp-tst-rde.mbu.local user=test1 comment=testuser uid=9990 
groups=sysadm"

I am getting this error...
 "msg": "argument groups is of type  and we were unable to 
convert to list:  cannot be converted to a list"

If I use the play book without groups parameter playbook is successful if I 
manually define groups directly in the playbook its successful but it fails 
if I use it with variables and I do not understand why 


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/05c5f71c-d6e6-4913-b25d-3bbeb3cbfccb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.