Re: [ansible-project] Comprehensive operator list / cheatsheet (needs a lot of work)

5,205 views
Skip to first unread message

Timothy Gerla

unread,
Apr 11, 2013, 12:08:48 PM4/11/13
to ansible-project
Hi Joel,

This is a great idea! I'd love to see it expanded with a short
description of each item. In 1.2 this list will also get simpler, with
the upgraded conditionals and the simplified variable access. But this
looks great and would be really helpful to a lot of people, I think.

-Tim

On Wed, Apr 10, 2013 at 4:07 AM, Joel Rebello <joel...@gmail.com> wrote:
>
> Hey,
>
> I realized I was writing up all these operators in my scratchpad so I can
> refer to them as a cheat sheet .
>
> I think it'll help a lot of users if we had some doc that comprehensively
> lists all possible ansible operators and links each one to a
> snippet/example ..
> The list below is based on the latest ansible release
>
> This list is not complete or correct, I'm hoping other ansible users can
> contribute and we end up some sort of doc that lists all of them :)
> Feel free to point out and flame me on things I may have missed out or are
> incorrect (I'm very much an ansible noob as of now)
>
>
>
> conditionals
> ===========
> when_failed:
> when_changed:
> when_string:
> when_boolean:
> when_integer:
> when_set:
> when_unset:
> only_if:
>
> Lookups
> =======
> with_items:
> with_sequence:
> with_fileglob:
> with_file:
> with_lines:
> with_pipe:
> with_env:
> with_dnstxt:
> with_template:
> with_redis_kv:
> with_password:
> first_found:
> with_nested:
> first_available_file:
>
>
> valid playbook definitions
> ========
> hosts:
> serial:
> gather_facts:
> connection:
> tasks:
> vars:
> vars_files:
> vars_prompt:
> sudo:
> user:
> sudo_user:
> roles:
>
>
> valid task parameters
> ==============
> name:
> include:
> action:
> notify:
> async:
> poll:
> tags:
> ignore_errors:
> local_action:
> delegate_to:
> environment:
> <module>
>
>
> Variables (non facts?)
> =========
> hostvars
> inventory_hostname
> group_names
> groups
>
>
> Accessing Variables
> ===================
> in playbooks:
> $varname OR ${varname}
> ${varname.<element>} # if its a list of lists
>
> in templates/jinja2:
> {{ varname }}
>
> --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Tim Gerla
t...@gerla.net

Lester Wade

unread,
Apr 11, 2013, 12:20:27 PM4/11/13
to ansible...@googlegroups.com
+1 Bazillion, this is very very useful indeed.

Michael DeHaan

unread,
Apr 11, 2013, 12:27:49 PM4/11/13
to ansible...@googlegroups.com
In 1.2, a little simpler:

conditionals
===========
when
(old forms supported for compat, but not needed)

some small errors:

first_found => with_first_found, which is the replacement to first_available_file
first_available_file <-- not a lookup plugin


inventory_hostname_short = the hostname in inventory with the stuff after the first "." chopped off.


Michael DeHaan <mic...@ansibleworks.com>
CTO, AnsibleWorks, Inc.
http://www.ansibleworks.com/

Brian Coca

unread,
Apr 11, 2013, 8:06:57 PM4/11/13
to ansible...@googlegroups.com

Nice, +1, this has been on my list for a while, thnx!

Brian Coca

lwade

unread,
Apr 17, 2013, 10:50:54 AM4/17/13
to ansible...@googlegroups.com
What's the best place for something like this?  I'd argue its so useful we should get something on the site asap.

Michael DeHaan

unread,
Apr 17, 2013, 2:38:36 PM4/17/13
to ansible...@googlegroups.com
There's already a glossary page on the doc site, perhaps extend that with a section or so?

I think it could also use some crosslinks to the rest of the documentation if folks would like to try to add them.


--
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.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Michael DeHaan

unread,
Apr 17, 2013, 2:39:15 PM4/17/13
to ansible...@googlegroups.com
It should also probably have a table/column format where we can add in when versions were added/or deprecated in favor of newer versions.


Gilles Cornu

unread,
Jun 20, 2013, 4:36:02 AM6/20/13
to ansible...@googlegroups.com
I'd like to reactivate this thread, since I would really enjoy having kind of handy concise cheat sheet... For instance, I'm now looking for all available facts and I have to use this template-dump trick to know available variables:

HOSTVARS (ANSIBLE GATHERED, group_vars, host_vars) :

{{ hostvars['wip-box'] | to_yaml }}

PLAYBOOK VARS:

{{ vars | to_yaml }}

Michael, would you accept an initial pull request to add a "cheat sheet" to official documentation ?

Jan-Piet Mens

unread,
Jun 20, 2013, 6:01:39 AM6/20/13
to ansible...@googlegroups.com
> Michael, would you accept an initial pull request to add a "cheat sheet" to
> official documentation ?

Of course he would [*], if you make it really, really good! ;-)

-JP

[*] Well, I'm hoping he would.

Serge van Ginderachter

unread,
Jun 20, 2013, 6:09:56 AM6/20/13
to ansible...@googlegroups.com


--

Michael DeHaan

unread,
Jun 20, 2013, 11:57:57 AM6/20/13
to ansible...@googlegroups.com
As long as it's part of the project source and easy to make patches to, sure.


Reply all
Reply to author
Forward
0 new messages