Summary of newly merged patches (since last update)

Hi Everyone,

Everybody's been busy and it's time for another update of all of the
cool things I've merged lately. This is all in the changelog now,
but here's an annotated explanation!

=== THE LIST ==

* output on failed playbook commands is now nicely split for
stderr/stdout and syntax errors

When running a playbook, If you have a command fail and a module gave
you three pages of output, it's nice to not have those stderr and
stdout messages inside the JSON curly brackets. It should now be
much more readable in those cases. (We may be doing a bit more of
this upgrade wise, but this is a start)

* if local_action is not used and delegate_to was 127.0.0.1 or
localhost, use local connection regardless

If someone decides to use delegate_to instead of the "local_action"
syntactic sugar, it should work exactly the same. This patch also
allows you to use a variable in "delegate_to".

* explicit quoting around only_if statements is no longer neccessary

No longer do you have to say:

only_if: "'$some_variable' == 'foo'"

You can now say:

only_if: '$some_variable' == 'foo'

* is_unset is also available in only_if in addition to is_set

This is now possible:

only_if: is_unset($some_variable)

Just like this was already possible:

only_if: is_set($some_variable)

* negative host matching (!hosts) fixed for external inventory script usage

If you are using inventory scripts to pull inventory from OpenStack
Nova, EC2, or Cobbler, (etc), this fixes the handling of negative
groups.

This is like when you would say:

hosts: all:!webservers

to select all hosts that aren't webservers. This already worked
before but there was a small bug with script based inventory data.

* pause plugin (pause seconds=10) (pause minutes=1) (pause prompt=foo)
action plugin

This is a cool new feature from Tim Bielawa. This allows you to
pause at arbitrary points of your play for X minutes or seconds, or
until a prompt is given.

When used with the "serial" keyword it will pause every N hosts,
otherwise it's once for all hosts.

- action: pause seconds=10
- action: pause minutes=3
- action: pause prompt='enter something to continue'

Etc. Try it out!

* cleaner error messages with copy if destination directory does not exist

Previously if you tried to copy into some remote directory
/that/did/not/exist it would tell you the destination was not
writeable. This wasn't too clear, so now it will tell you that the
directory
does not exist, when it in fact does not exist :slight_smile:

* internals: os.executable check replaced with utils function so it
plays nice on AIX

If you're using ansible to talk to AIX nodes, this fixes a few checks
throughout the app. Developers should use utils.is_executable or
module.is_executable where you need similar
behavior elsewhere.

* when running a playbook, and the statement has changed, prints
'changed:' now versus 'ok:' so it is obvious without colored mode

When running without colors enabled (NOCOLOR=1, not supporting color
in your terminal, etc) it wasn't easy to tell when something resulted
in a change state when running your playbook. Now when things have
changed, it prints "changed" vs just "ok".

* variables now usable within vars_prompt (just not host/group vars)

This is kind of a rare thing, but if you want to define a variable
message to prompt with in vars_prompt, you can now do that.

* setup module now still works if PATH is not set

Pretty much as it says, if you for some reason don't have a PATH set,
the setup module now won't choke.

* Debian packaging now includes ansible-pull manpage

* magic variable 'ansible_ssh_host' can override the hostname (great
for usage with tunnels)

This has been needed for a while. What if you have lots of tunnels
and stuff? Well, you can do this!

[servers]
alias1 ansible_ssh_port=1234 ansible_ssh_host=bastion
alias2 ansible_ssh_port=1235 ansible_ssh_host=bastion
alias3 ansible_ssh_port=1236 ansible_ssh_host=bastion

And now you can easily express that kind of setup in your inventory
file. Previously you had to use resolv.conf to implement aliases.

* service module status now correct for services with 'subsys locked' status

* misc fixes/upgrades to the wait_for module

* date command usage in build scripts fixed for OS X

* git module now expands any "~" in provided destination paths

If you do dest=~/somedir the git module now works with that data.

Minor retraction for 0.8 features -- you *do* have to quote python
expressions in "only_if".

We hit a minor snag about using variables like:

only_if: $saved_conditional

and had to back that one out.

Hi Everyone,

Everybody’s been busy and it’s time for another update of all of the
cool things I’ve merged lately. This is all in the changelog now,
but here’s an annotated explanation!

=== THE LIST ==

  • output on failed playbook commands is now nicely split for
    stderr/stdout and syntax errors

When running a playbook, If you have a command fail and a module gave
you three pages of output, it’s nice to not have those stderr and
stdout messages inside the JSON curly brackets. It should now be
much more readable in those cases. (We may be doing a bit more of
this upgrade wise, but this is a start)

  • if local_action is not used and delegate_to was 127.0.0.1 or
    localhost, use local connection regardless

If someone decides to use delegate_to instead of the “local_action”
syntactic sugar, it should work exactly the same. This patch also
allows you to use a variable in “delegate_to”.

  • explicit quoting around only_if statements is no longer neccessary

No longer do you have to say:

only_if: “‘$some_variable’ == ‘foo’”

You can now say:

only_if: ‘$some_variable’ == ‘foo’

  • is_unset is also available in only_if in addition to is_set

This is now possible:

only_if: is_unset($some_variable)

Just like this was already possible:

only_if: is_set($some_variable)

  • negative host matching (!hosts) fixed for external inventory script usage

If you are using inventory scripts to pull inventory from OpenStack
Nova, EC2, or Cobbler, (etc), this fixes the handling of negative
groups.

This is like when you would say:

hosts: all:!webservers

to select all hosts that aren’t webservers. This already worked
before but there was a small bug with script based inventory data.

  • pause plugin (pause seconds=10) (pause minutes=1) (pause prompt=foo)
    action plugin

This is a cool new feature from Tim Bielawa. This allows you to
pause at arbitrary points of your play for X minutes or seconds, or
until a prompt is given.

When used with the “serial” keyword it will pause every N hosts,
otherwise it’s once for all hosts.

  • action: pause seconds=10
  • action: pause minutes=3
  • action: pause prompt=‘enter something to continue’

Etc. Try it out!

  • cleaner error messages with copy if destination directory does not exist

Previously if you tried to copy into some remote directory
/that/did/not/exist it would tell you the destination was not
writeable. This wasn’t too clear, so now it will tell you that the
directory
does not exist, when it in fact does not exist :slight_smile:

  • internals: os.executable check replaced with utils function so it
    plays nice on AIX

If you’re using ansible to talk to AIX nodes, this fixes a few checks
throughout the app. Developers should use utils.is_executable or
module.is_executable where you need similar
behavior elsewhere.

  • when running a playbook, and the statement has changed, prints
    ‘changed:’ now versus ‘ok:’ so it is obvious without colored mode

When running without colors enabled (NOCOLOR=1, not supporting color
in your terminal, etc) it wasn’t easy to tell when something resulted
in a change state when running your playbook. Now when things have
changed, it prints “changed” vs just “ok”.

  • variables now usable within vars_prompt (just not host/group vars)

This is kind of a rare thing, but if you want to define a variable
message to prompt with in vars_prompt, you can now do that.

  • setup module now still works if PATH is not set

Pretty much as it says, if you for some reason don’t have a PATH set,
the setup module now won’t choke.

  • Debian packaging now includes ansible-pull manpage

  • magic variable ‘ansible_ssh_host’ can override the hostname (great
    for usage with tunnels)

This has been needed for a while. What if you have lots of tunnels
and stuff? Well, you can do this!

[servers]
alias1 ansible_ssh_port=1234 ansible_ssh_host=bastion
alias2 ansible_ssh_port=1235 ansible_ssh_host=bastion
alias3 ansible_ssh_port=1236 ansible_ssh_host=bastion

And now you can easily express that kind of setup in your inventory
file. Previously you had to use resolv.conf to implement aliases.

Sorry to bug about this all the time. Is this feature working?

I’ve tried it with:

$ cat hosts.ini

[all]
dev-aggregator01 ansible_ssh_port=60001 ansible_ssh_host=10.120.137.181

$ ansible all -i ./hosts.ini -m shell -a “uptime”
dev-aggregator01 | FAILED => FAILED: %d format: a number is required, not str

Ok, i removed the “dev-” part and now the error turns into:

$ cat hosts.ini

[all]
aggregator01 ansible_ssh_port=60001 ansible_ssh_host=10.120.137.181

$ ansible all -i ./hosts.ini -m shell -a “uptime”
aggregator01 | FAILED => FAILED: [Errno -2] Name or service not known

Also,

$ telnet 10.120.137.181 60001
Trying 10.120.137.181…
Connected to 10.120.137.181.
Escape character is ‘^]’.
SSH-2.0-OpenSSH_5.9p1

I’ve tried 0.6, 0.7.2 and 0.8 (devel 4abf23d34d).

What am I doing wrong here?

You have to put those on the same line as the host. Also host:port is an easier syntax. See the examples dir in the checkout.

– Michael

You have to put those on the same line as the host. Also host:port is an easier syntax. See the examples dir in the checkout.

– Michael

Oh, don’t know how you see the formatting, in Google Groups they show on the same line. So yeah, it’s a single line “host ansible_ssh_port=X ansible_ssh_host=Y”.

host:port would work for me only if I can set an alias which I can then use in playbooks, because my host file would look like:

[all]
10.1.2.3:1000
10.1.2.3:1001

10.1.2.3:someotherport

each of these being a different host.

So if I could write:

[all]
10.1.2.3:1000 alias=host1

and use “host1” in playbooks, that’d be great, but not sure if it’s possible, I’m still digging through the documentation and mailing list messages.

Cosmin

+1I don’t understand what Michael meant by “on the same line”

"ansible_ssh_host" is that alias, exactly.

Requires 0.8.

If using ssh as a transport (-c ssh) you can also setup host aliases that include the ports in your .ssh/config

% ansible-playbook --version
ansible-playbook 0.8 (devel 4abf23d34d) last updated 2012/10/17 17:46:20 (GMT +300)

% cat hosts.ini
[all]
10.120.137.181:60001 ansible_ssh_host=foobar

% cat test.yaml

If using ssh as a transport (-c ssh) you can also setup host aliases that include the ports in your .ssh/config

Yeah, I could do this, but it’s not much better than what we’re doing at work, i.e. having a custom /etc/hosts with “aliases”.

As an alternate when using ssh as a transport, you can do the following in your ~/.ssh.config

Host myhostalias
HostName 10.1.0.123
Port 3324

Shouldn’t this be

foobar ansible_ssh_host=10.120.137.181:60001

?

Nope, does not work like that currently

– Michael

Cosmin Luță wrote:

"ansible_ssh_host" is that alias, exactly.

Requires 0.8.

% ansible-playbook --version
ansible-playbook 0.8 (devel 4abf23d34d) last updated 2012/10/17 17:46:20
(GMT +300)

% cat hosts.ini
[all]
10.120.137.181:60001 ansible_ssh_host=foobar

No, you want
foobar ansible_ssh_host=10.120.137.181 ansible_ssh_port=60001

Daniel

The colon is just another way of passing the port, in other words

-- Michael

Cosmin Luță wrote:

“ansible_ssh_host” is that alias, exactly.

Requires 0.8.

% ansible-playbook --version
ansible-playbook 0.8 (devel 4abf23d34d) last updated 2012/10/17 17:46:20
(GMT +300)

% cat hosts.ini
[all]
10.120.137.181:60001 ansible_ssh_host=foobar

No, you want
foobar ansible_ssh_host=10.120.137.181 ansible_ssh_port=60001

Daniel

Yeah, I thought so too, but if you check my first reply in this thread, you’ll see that I’ve already tried this and it’s not working :frowning:

It works, tested last night.

– Michael

I’ve tried with a clean checkout (whole session here http://pastebin.com/jCt1auAq ) and still doesn’t do the right thing.
Could you point me to a commit-id where this is functional ?
Otherwise, I’ll just drop it and consider this one of those things that work for everyone else but you :))

It works, tested last night.

– Michael

Could you point me to a commit-id where this works?

Cosmin Luță wrote:

I've tried with a clean checkout (whole session here
http://pastebin.com/jCt1auAq ) and still doesn't do the right thing.
Could you point me to a commit-id where this is functional ?
Otherwise, I'll just drop it and consider this one of those things that
work for everyone else but you :))

It was broken recently. I've submitted a PR to fix it, but
339c05bb88a2ab6d3585c45c7a61812ed8e0af5b~1 will work until that is merged.

Daniel

Your pull request breaks some other behaviors that are important with
delegated hosts, I'll review it and see what changes I may want to
make.