[ansible-project] Re: use vars from include_role

2017-05-28 Thread Trond Hindenes
This was discussed in another thread. Seems to be a bug in the 
"include_role" module

On Friday, May 26, 2017 at 12:14:48 AM UTC+2, Michael Ströder wrote:
>
> HI! 
>
> I want to use the following task (with ansible ansible-2.3.1.0-0.2.rc2): 
>
> - name: "Install web2ldap on {{ openldap_role }}" 
>   include_role: 
> name: web2ldap 
> private: False 
>   vars: 
> web_server: "apache2" 
> web2ldap_pip_index_url: "{{ aedir_pip_index_url }}" 
> web2ldap_pip_needs_compiler: "{{ aedir_pip_needs_compiler }}" 
> web2ldap_pip_extra_args: "{{ aedir_pip_extra_args }}" 
>   when: openldap_role=="provider" 
>
> The role sets some vars that are used in later tasks. 
>
> If I execute the role itself before another role in the same playbook 
> web2ldap's vars are 
> present an can be used. But not with the include_role task above. 
>
> Any hint what's going on is highly appreciated. 
>
> Ciao, Michael. 
>
>

-- 
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/3e324427-61cc-4591-ba26-4661267f229d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible 2.1.0 - How to avoid dashes error with rendering templates (like my.cnf)

2017-05-28 Thread Sukhdeep Singh Aulakh

>
> I was also having  the same error,
>>
>  

> I was substituting the variable like this {{var_property1-role}} , 
>>
>  

> ansible doesn't permit - in variable names so by changing 
>>
>  

> {{var_property1-role}} to {{var_property1_role}} it worked fine.
>
>
Your post was of great help.

Thanks,
Sukhdeep 

-- 
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/e9297a5f-ffd2-44c8-84e1-70ccb17a1ac0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Staggering unarchive module requests

2017-05-28 Thread Guy Knights
I have a task that uses the unarchive module to download a source package
from a site on the internet. However, I'm getting an HTTP 429 "Too many
requests" message when this task runs, as the parallel calls from multiple
hosts are making the request at the same time.

Is there any simple way to stagger these requests? I know the 'serial'
option exists but that only works at the playbook level and I definitely
don't want to serialise every task in this role.

Thanks,
Guy

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


Re: [ansible-project] Lineinfile - replacing regex instead of placing text after insertafter

2017-05-28 Thread Kai Stian Olstad

On 28. mai 2017 11:53, Listing wrote:

Hi guys,

I have some problems with the lineinfile module. I try to add
'inserted_text' after '#insertbelow' when 'this' has been found in
/etc/ansible/lineinfile/lol. This is my task:


That is not how lineinfile work.
It searches for a string, and replace it or add the line.

To do this you would need to combine find module to search for "this" 
and then run lineinfile on the file.


--
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/042e6161-2970-af1e-8270-da6ddf22b8b5%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Expect module throwing up an error while passing responses

2017-05-28 Thread Kai Stian Olstad

On 26. mai 2017 21:44, Murthy Vipparthy wrote:

*Thank you Kai for response. Unfortunately this did NOT work. Let me
explain this scenario once again.*

*Here is Complete expect Module Code.*

- name: Perform auto prompt for *responses*
 expect:
   chdir: /tools/murthy/AOCL-SDK-16.0
   command: /bin/bash setup_pro.sh
   responses:
  'Press \[Enter\] to continue:': \n
  '--More--' : \r

   timeout: 180
   echo: yes

   - name: Perform auto prompt for *responses2*
 expect:
   chdir: /tools/murthy/AOCL-SDK-16.0
   command: /bin/bash setup_pro.sh
   responses:
  'Do you accept this license\? \[y/n\]': y\n
   echo: yes


*Here is Error and final OUT PUT @ below, Can you explain whether first
expect module being executed ?? I am suspecting this command NOT being
executed and timeout happening. When I run manually from terminal, I need
to press [Enter] command @ least 20 times and works OK. but when I use this
expect module, I am NOT able GET this work. I have also separated two
responses also for easy debugging.*

fatal: [10.10.10.147]: FAILED! => {
 "changed": true,
 "cmd": "/bin/bash setup_pro.sh",
 "delta": "0:03:07.381255",
 "end": "2017-05-26 12:21:14.170676",
 "failed": true,
 "invocation": {
 "module_args": {
 "chdir": "/tools/murthy/AOCL-SDK-16.0",
 "command": "/bin/bash setup_pro.sh",
 "creates": null,
 "echo": true,
 "removes": null,
 "responses": {
 "--More--": "\\r",
 "Press \\[Enter\\] to continue:": "\\n"
 },
 "timeout": 180
 }
 },
 "msg": "command exceeded timeout",
 "rc": null,
 "start": "2017-05-26 12:18:06.789421",



Also OUTPUT here


"",
 "",
 "Press [Enter] to continue:\\n",
 "",
 "",
 "Do you accept this license? [y/n]: "
 ]
}
You can't split the task in two, now the first task is waiting for a 
response on "Do you accept this license? [y/n]:", but since your first 
task doesn't contain that. It hang until the timeout and you get a 
failed task and the play aborts.


--
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/56bf1bb2-26bb-983b-a1c9-abe10f847734%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] error message

2017-05-28 Thread Kai Stian Olstad

On 24. mai 2017 23:08, Daley Okuwa wrote:

hello when i  try to  run this command
ansible all -i hosts -s --sudo  -m ping

I get this error message

192.168.85.129 | UNREACHABLE! => {
 "changed": false,
 "msg": "Failed to connect to the host via ssh: Permission denied
(publickey,password).\r\n",
 "unreachable": true

Please tell me what i am doing wrong
Normally i can ssh into this hosts 192.168.85.129
from the control server


Are you using keys or password?
If you are using password you are missing -k/--ask-pass option.

--
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/2d2fb400-91bf-3801-e012-4345b7f326cb%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] How to edit a variable in a later variable file

2017-05-28 Thread Kai Stian Olstad
On 22. mai 2017 19:01, Adam Lininger wrote:
> I would like to be able to edit a variable (per host) that was originally
> defined in a default file.

You can overwrite variables per host, but not edit or partial overwrite a 
variable.


> The larger situation is this. We have a large number of servers with a
> defined set of local accounts. The list of accounts is defined something
> like this in the default.yml file for the role. The task in the role
> iterates over the list and creates all the accounts using the user module.
> 
> list_of_users:
>   - username: user1
> state: present
> shell: /bin/bash
> password_hash: 
> 
>   - username: user2
> state: present
> shell: /bin/zsh
> password_hash: 
> 
> Ideally, I'd like to be able to trim down the list of users to a much
> smaller set on a per-host basis. I don't want to have to edit the per host
> file when the main file adds a new user. I also don't want to have to
> change passwords or shells in every per-host file (which is what I'm doing
> now).
> 
> The ideal case would be to (in a host_vars or group_vars file) iterate over
> the list_of_users array and change the state variable to absent...except
> when username matches a local list.
> 
> It seems like such a thing should be possible somehow, but I haven't found
> any way of doing that.
What you could do is introduce a list variable called enabled_users.
Then you can list all the user that you would like to create on a host, and the 
role has all the users.

If you need to overwrite some of the values you could do something like 
list_of_user_overwrite.

- user:
name: "{{ list_of_user_overwrite[item.username] | default(item.username) }}"
state: "{{ list_of_user_overwrite[item.state] | default(item.state) }}"
...
...
  when: item.username in enabled_users
  with_items: "{{ list_of_users }}"

-- 
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/d1d5e0dc-9839-752c-a497-1d6445420912%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Error doing ansible ping on VM

2017-05-28 Thread Bob Nian
I am running CentOS on my bare-metal installation of esxi 6.5 host . While 
I am able to do ansible ping to my esxi 6.5 host from my Master Node that's 
running Ubuntu, I am unable to do ansible ping my CentOS using 'ansible -m 
ping all' even though I am being able to do normal ssh from my CentOS to my 
Master Node and from Master Node to CentOS. 

*Host file*
esxi-host
root@192.168.1.10

*Output after running 'ansible -m ping all'*
esxi-host | SUCCESS => {
"changed": false, 
"ping": "pong"
}
root@192.168.1.10 | FAILED! => {
"failed": true, 
"msg": "failed to transfer file to 
/root/.ansible/tmp/ansible-tmp-1495975641.67-89953239612864/ping.py:\n\nssh: 
Could not resolve hostname 192.168.1.10]: Name or service not known\r\nlost 
connection\n"
}

Even after trying to put scp_if_ssh=True on my ansible.cfg, this still 
happen. Any help would be appreciated!



-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To 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/82c91b76-6589-45b1-8bf9-b1e6f25a7157%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Using powercli in Ansible

2017-05-28 Thread Bob Nian
This is because I've to harden my vSphere esxi host using script (powercli) 
and thus I will be using ansible to automate the script. However, after 
reading through the vmware_guest module, it seems like the module does not 
have that relation to what I am doing. Is there anyway that I can 
incorporate powercli scripts to ansible or is there any module that has 
some sort of relation of esxi hardening?

-- 
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/5cae6726-1b1d-4959-b2cb-7193b7ef5745%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Lineinfile - replacing regex instead of placing text after insertafter

2017-05-28 Thread Listing
Hi guys,

I have some problems with the lineinfile module. I try to add 
'inserted_text' after '#insertbelow' when 'this' has been found in 
/etc/ansible/lineinfile/lol. This is my task:

---
- hosts: localhost
  tasks:
  - name: lol
lineinfile:
  path: /etc/ansible/lineinfile/lol
  regexp: '^this'
  insertafter: '^#insertbelow'
  line: 'inserted_text'


This is the content of the lol file:

adsfsadfasdf
this

asdfasdf

#insertbelow

adfasdf

adsfa




When running the playbook, this is the result:

adsfsadfasdf
*inserted_text*

asdfasdf

#insertbelow

adfasdf

adsfa


When running the playbook again, this is the result:

adsfsadfasdf
*inserted_text*

asdfasdf

#insertbelow
*inserted_text*

adfasdf

adsfa

(and after running it again, it keeps adding after #insertbelow).

What the heck? It just replaced the regex text instead of placing it after 
#insertbelow. Am I doing something wrong?

-- 
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/6ee6dffe-5157-4ccf-ac95-a3c973d75646%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Docker CD with ansible

2017-05-28 Thread Sergey Baranov
Hello,

I'm going to create CD for a project on docker (nginx image, drupal image, 
drush image) using ansible.
Pulling images from a private docker registry that were built and pushed on 
previous pipeline step.
What is more convenient ansible module for these purposes: docker_container 
or docker_service? 
Tried both modules: single ansible task that deploys 3 containers using 
docker_service and multiple ansible tasks using docker_container module.
Both works but I would like to hear advice from people who have had 
experience with this.
In which cases is it better to use each of these modules?

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/e4a7374f-9607-44ea-bb70-26bb07b193ef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.