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.


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

2017-01-04 Thread Kai Stian Olstad

On 04. jan. 2017 13:25, Cosimo Streppone wrote:

That's right. I had "gathering=explicit" in my configuration file,
since I had used ansible only for command execution, and obviously
gathering facts was wasting lots of time for those kind of tasks.

Thanks, that clears it.

I tried overriding my configuration file from the command line:

  ansible-playbook -v -l  -e gather_facts=true ./playbook.yml

and:

  ansible-playbook -v -l  -e gathering=implicit ./playbook.yml

but none worked.
Changing the playbook file by adding "gather_facts: true" worked
instead.
Not sure if that's an accepted practice. Opinions?


gather_facts and gathering is a directive not a variables, so thats why 
-e didn't work.

gather_facts can only be used in a play.

--
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/7e75dda0-0310-cdb1-f7dc-a365de1a45a7%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


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

2017-01-04 Thread Andreas Olsson
ons 2017-01-04 klockan 13:25 +0100 skrev Cosimo Streppone:
> ...
> I'm still unsure about this error message when the facts gathering is
> not happening:
> 
> "Could not detect which package manager to use. Try gathering facts
> or setting the \"use\" option."
> 
> what is the "use" option?

See https://docs.ansible.com/ansible/package_module.html

  - package:
      name: emacs
  use: apt

... which is a bit of a pointless exercise. What might make more sense
then is something along these lines.

  - package:
      name: emacs
  use: "{{ host_alt_group_variable }}"


// Andreas

-- 
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/1483555376.9288.4.camel%40arrakis.se.
For more options, visit https://groups.google.com/d/optout.


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

2017-01-04 Thread Cosimo Streppone
On Wed, Jan 4, 2017, at 05:42, Andreas Olsson wrote:

> Indeed it looks as if facts aren't being gathered, which is kind of
> odd, since it should happen by default. By then each play should
> contain the following at the start.
> 
>   TASK [setup]
>   ***
>   ok: [localhost.localdomain]

I found no indication of this in my run log, so facts gathering was
not happening.

> Any chance that your ansible.cfg has a non-default value for the
> gathering[1] option? Such as it being set to explicit?

That's right. I had "gathering=explicit" in my configuration file,
since I had used ansible only for command execution, and obviously
gathering facts was wasting lots of time for those kind of tasks.

Thanks, that clears it.

I tried overriding my configuration file from the command line:

  ansible-playbook -v -l  -e gather_facts=true ./playbook.yml

and:

  ansible-playbook -v -l  -e gathering=implicit ./playbook.yml

but none worked.
Changing the playbook file by adding "gather_facts: true" worked
instead.
Not sure if that's an accepted practice. Opinions?

I'm still unsure about this error message when the facts gathering is
not
happening:

"Could not detect which package manager to use. Try gathering facts or
setting the \"use\" option."

what is the "use" option?

Thanks,

-- 
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/1483532743.3173353.836972801.7CA4C1BE%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.


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

2017-01-03 Thread Andreas Olsson
Hello Cosimo

Indeed it looks as if facts aren't being gathered, which is kind of
odd, since it should happen by default. By then each play should
contain the following at the start.

  TASK [setup] 
***
  ok: [localhost.localdomain]

Any chance that your ansible.cfg has a non-default value for the
gathering[1] option? Such as it being set to explicit?

// Andreas

[1]: https://docs.ansible.com/ansible/intro_configuration.html#gathering

-- 
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/1483504967.2513.1.camel%40arrakis.se.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Help with package installation playbook

2017-01-03 Thread Cosimo Streppone
Hi,

have started evaluating ansible playbook functionality to perform
simple config management tasks.

I have experienced several problems. Tried to get some help on irc,
and through web searches, but.. well. I'm here :)

I'm running the following playbook:

---8<---
# test.yml
---
- hosts: all
  become: yes
  tasks:

  - name: Install hoardr-client for RedHat/CentOS
yum: "name={{ item }} state=installed"
with_items:
  - hoardr-client
when: ansible_pkg_mgr == 'yum'

  - name: Install hoardr-client for Debian/Ubuntu
apt: "name={{ item }} update_cache=yes"
with_items:
  - hoardr-client
when: ansible_pkg_mgr == 'apt'
---8<---

(more on this playbook later)

What happens is that the "when:" condition seems to fail
miserably (wrapping is likely to destroy this, so
http://pastebin.com/YtcNuxnj holds the original):

---8<---
# Running: ansible-playbook test.yml
TASK [Install hoardr-client for RedHat/CentOS]
*
fatal: [localhost.localdomain]: FAILED! => {
"failed": true,
"msg": "The conditional check 'ansible_pkg_mgr == 'yum'' failed.
The error was: error while evaluating conditional
(ansible_pkg_mgr == 'yum'): 'ansible_pkg_mgr' is undefined
The error appears to have been in
'/home/cosimo/src/sys/ansible/test.yml': line 9, column 5, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
  - name: Install hoardr-client for RedHat/CentOS
^ here"}
to retry, use: --limit @/home/cosimo/src/sys/ansible/test.retry
---8<---

I traced this back to facts gathering not working for some reason.
Next step I tried:

ansible -m setup  | grep ansible_pkg_mgr
"ansible_pkg_mgr": "apt",

it would seem the answer I got was correct,
so what is going wrong here?

Side notes:

1) searching around, I found instances of the following syntax:

 when: "'$ansible_pkg_mgr' == 'yum'"

   This is not working either. I hope this is on purpose :-)

2) I found a `package' directive, which I'd really wish I could use,
   instead of yum/apt alternate code paths. When I try it,
   I get the following error message:

   ... cannot detect which package manager to use: try gathering facts
   or setting the "use" option.

   What is the "use" option? I can't seem to find it anywhere.

Thanks for at least reading through this,

-- 
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/9bf7850e-53ad-f63b-0e38-3859f2ca62db%40streppone.it.
For more options, visit https://groups.google.com/d/optout.