Re: [ansible-project] Using ansible's inventory to ssh

2015-08-19 Thread Michael Peters
Sounds like you're wanting to be able to ssh to a machine based on it's name instead of it's ip address. DNS is the obvious answer. If not that, then maybe create an ansible playbook that generates an /etc/hosts file for your control server based on the servers in the inventory. Then you can just

Re: [ansible-project] Inconsistent boolean handling of False

2015-06-23 Thread Michael Peters
This bug should be fixed. Which version are you using? But even when it's fixed, the string false is a true value. I do admit that |bool everywhere is kind of annoying, but it's the safest way to always make sure your context is correct. On Tue, Jun 23, 2015 at 12:31 PM, Si W wools...@gmail.com

Re: [ansible-project] When did role-level library/ directories become supported?

2015-06-15 Thread Michael Peters
, Brian Coca bc...@ansible.com wrote: iirc when roles were added. On Mon, Jun 15, 2015 at 12:12 PM, Michael Peters michael00pet...@gmail.com wrote: I've looked at the documentation on the site (https://docs.ansible.com/playbooks_roles.html) that describes this feature, but it doesn't indicate

[ansible-project] When did role-level library/ directories become supported?

2015-06-15 Thread Michael Peters
(which was introduced in 0.5). Does anyone know when this feature was added? Thanks, -- Michael Peters -- 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

Re: [ansible-project] Forced Fact Gathering

2015-06-08 Thread Michael Peters
If we went that route, we should use the exsiting host pattern syntax: http://docs.ansible.com/intro_patterns.html On Mon, Jun 8, 2015 at 4:51 PM, Craig Tracey craigtra...@gmail.com wrote: What if instead of gather_facts: force we develop a mechanism that is simple in nature like:

Re: [ansible-project] Automate install of the controller

2015-06-03 Thread Michael Peters
I put it in ansible like everything else. And then bootstrap the control node from my laptop (either a Mac or Linux laptop). And there after I run that same ansible script on the control node against itself. On Wed, Jun 3, 2015 at 5:47 AM, jaysmythe...@gmail.com wrote: Is there a recomended way

Re: [ansible-project] Ansible coming from a Fabric perspective

2015-05-21 Thread Michael Peters
Actually, I prefer to have separate playbooks for configuration management and deployment. The 1st rarely involves orchestrating servers in anything complicated where ordering matters. And the 2nd almost always involves ordered steps across multiple servers. That way things can deployed without

Re: [ansible-project] Clone VMs on vSphere

2015-05-13 Thread Michael Peters
You can pass it as variable through the command line and then use a fail task to abort unless it's been set. That's how I've done similar things in the past. On Wed, May 13, 2015 at 3:37 AM, Marcel Bezemer mar...@beestig.nl wrote: Hey, I am currently playing around with ansible to see if this

Re: [ansible-project] Force fact-gathering on all hosts when using -limit

2015-05-04 Thread Michael Peters
is flushed, or on a new system that was not loaded with the cache? -- Michael Peters On Mon, May 4, 2015 at 9:49 AM, Brian Coca bc...@ansible.com wrote: Another way around this is using persistent fact caching. -- Brian Coca -- You received this message because you are subscribed

Re: [ansible-project] Force fact-gathering on all hosts when using -limit

2015-05-04 Thread Michael Peters
Gotcha, thanks! On Mon, May 4, 2015 at 10:37 AM, Brian Coca bc...@ansible.com wrote: It is not the solution, but it is a workaround available now. On my list i have being able to 'delegate' facts so we can do something like: setup: set_for={{item}} delegate_to: {{item}}' with_items:

Re: [ansible-project] Parallel execusion of task with arguments

2015-04-19 Thread Michael Peters
I would use a dictionary where the keys are the hostnames. Then the task would pull the variable it needs. -- Michael Peters On Apr 18, 2015 10:09 PM, Maruti Kumar maruti.gollap...@gmail.com wrote: Need to execute a tak on muntiple nodes in parallel. And each execution takes one value from

Re: [ansible-project] Tiered application start/stop orchestration ordering

2015-03-24 Thread Michael Peters
I don't know if this helps, but I usually use roles for configuration management and use standalone playbooks for orchestration stuff. I've just found it easier to have more control if I centralize certain aspects (like say an application upgrade) in a single playbook instead of spread around in

Re: [ansible-project] register shell output, set as custom fact and use it as a condition of the playbook running

2015-03-12 Thread Michael Peters
You're trying to compare a structure to a string. You probably meant to use git_installed_version in your when conditional. Also, you either need to quote the {{ git_version }} in the conditional so that the string is quoted, or just leave it off entirely since it's using 2 variables, no need to

Re: [ansible-project] Setting ANSIBLE_HOST_KEY_CHECKING per host

2015-03-05 Thread Michael Peters
Can you really set ansible_ssh_args per group/host? I remember trying it a while ago and it didn't work. And it's not mentioned here: http://docs.ansible.com/intro_inventory.html#list-of-behavioral-inventory-parameters I'll admit I haven't tried it in a while, but can someone confirm that it

Re: [ansible-project] Best client platform to run Ansible from?

2015-03-04 Thread Michael Peters
If you are having SSH problems (really network problems), I've noticed a big improvement when I run ansible from within the cluster that it's managing. It's trickier if your server farm is spread out across multiple DCs/clouds. But it's still more reliable than running it from your laptop on a

Re: [ansible-project] Re: Review of the upcoming Vagrant Ansible Local Provisioner

2015-02-23 Thread Michael Peters
One use-case that you might not have thought of is developers using Windows, even if the target machine is Linux. I had this problem on a previous team and had to hack our own provisioning step to use the shell and run vagrant locally. Windows will probably never be able to run vagrant. But why

Re: [ansible-project] Re: Steps for ssh forwarding?

2015-02-13 Thread Michael Peters
Not the answer you're looking for, but why don't you just use ssh keys? It's some minor work upfront with huge security and automation benefits easier. On Fri, Feb 13, 2015 at 3:51 PM, Ananda Debnath ananda.debn...@gmail.com wrote: Does anyone know of an example to do this using password

Re: [ansible-project] Re: Host-based files and templates

2015-02-09 Thread Michael Peters
On Mon, Feb 9, 2015 at 10:55 AM, ProfHase profhas...@gmail.com wrote: @Michael Peters: I am using monit for monitoring. And depending on machine there are completely different services to monitor. I could also do multiple roles like 'monit_webservice' , 'monit_db', 'monit_application_a

Re: [ansible-project] Re: Host-based files and templates

2015-02-09 Thread Michael Peters
On Mon, Feb 9, 2015 at 12:18 PM, ProfHase profhas...@gmail.com wrote: Do you have any idea what to do about the machine-specific ssl-certificates? Again, I can't think of a valid machine-specific ssl certificate case. It should be based on roles, right? But I liked Brian Coca's ealier comment

Re: [ansible-project] Host-based files and templates

2015-02-06 Thread Michael Peters
If your monitoring configuration differs too much between machines, I think you might be doing it wrong. I can definitely understand how it would be different per group/role (db vs web, etc) but how would it differ between machines of the same role? On Fri, Feb 6, 2015 at 8:46 AM, ProfHase

Re: [ansible-project] Shortcut for making Ansible groups from EC2 tags

2014-12-16 Thread Michael Peters
Another option I've used is to modify the ec2.py that comes in the ansible sample inventories. For something simple like this it's not a big deal, but when you start having more custom groups based on tags and you don't want the ec2_tag_ prefix on every group (or are mixing EC2 and non-aws

Re: [ansible-project] Using when and not

2014-12-09 Thread Michael Peters
There was a bug in ansible where when a variable foo is the string false it interprets both foo and not foo as true. https://github.com/ansible/ansible/issues/8629 But this bug is for an old version of ansible. Which version are you using? On Tue, Dec 9, 2014 at 5:21 PM, Matt Hughes

Re: [ansible-project] Using ansible facts in playbooks

2014-11-25 Thread Michael Peters
First, that's a really old version of ansible, and you need to upgrade. Second, the when clause uses jinja syntax and it's complaining that it can't evaluate your syntax: it's a syntax error, not a fact error. In jinja, the not needs to come before the expression it's negating. Try something like

Re: [ansible-project] Seemingly simple template driving me mad

2014-11-24 Thread Michael Peters
In this case fred is the key to the exports dictionary. It can't be both the key and the entry itself. Try something like: {{ fred }} {{ exports[fred].options }} On Sun, Nov 23, 2014 at 6:35 AM, Stephen Tan s...@stanandliz.net wrote: Hi - I'm doing something which seems very simple - trying

Re: [ansible-project] How to use variable template in shell or command

2014-11-19 Thread Michael Peters
Instead of quoting each individual value, quote the whole line like this: - name: Run the setup script shell: {{ SITE_DIR }}/setup_jibs.sh creates={{ item }}/run_setup_jibs_DO_NOT_REMOVE.sh On Wed, Nov 19, 2014 at 1:47 AM, Steve Kieu msh.comput...@gmail.com wrote: Hi everyone, I want to

Re: [ansible-project] Conditional and include

2014-11-19 Thread Michael Peters
When you put a conditional on an include ansible adds that conditional to each task in the include. So this is the expected behavior. On Wed, Nov 19, 2014 at 12:39 PM, John Oliver jno...@gmail.com wrote: My playbook: - name: Get Java version shell: /Library/Internet\

Re: [ansible-project] Force re-read of dynamic inventory script?

2014-11-17 Thread Michael Peters
No, but you can add the machine to the necessary groups when you use add_host after its created. On Mon, Nov 17, 2014 at 4:57 PM, Josh Smift j...@care.com wrote: I feel like I've seen questions like this on the list before, but I'm having a hard time finding one now; apologies if this is old

Re: [ansible-project] Force re-read of dynamic inventory script?

2014-11-17 Thread Michael Peters
You could try abstracting out the logic into a separate script that both your inventory and your provisioning playbook could call to determine which groups to put it in. I agree that it's a bit of a pain. I'd really like to have this be possible as well since it would really simplify some

Re: [ansible-project] Multiple all groups?

2014-11-13 Thread Michael Peters
You can have a directory underneath group_vars. Something like: group_vars/all/ + secret.yml + public.yml Where secret.yml is vault encrypted. On Thu, Nov 13, 2014 at 2:51 PM, Jacob Weber weberja...@gmail.com wrote: I know we can have group_vars/all, which will apply to all hosts. But is

Re: [ansible-project] Strange behaviour, possible bug

2014-11-11 Thread Michael Peters
Adding a when condition to an include doesn't conditionally include the file, it instead adds that condition to every task in that file. So in this case yes, the debug does have the when statement. On Tue, Nov 11, 2014 at 11:53 AM, cdar z cda...@gmail.com wrote: But debug doesn't have when

Re: [ansible-project] tag_Name issue with ec2.py

2014-11-10 Thread Michael Peters
This is because tags are not properties on the instance objects. I do agree that it's weird that you can only pick properties of the underlying python object for the destination variable. The list of those properties is available here:

Re: [ansible-project] Re: Why does Ansible change to looking for the group name in ssh config if you add a group of groups.

2014-11-03 Thread Michael Peters
The children of a group in the inventory are assumed to be hostnames, not other groups. This is why ssh is trying to find that groupname in the ssh config, because it's supposed to be a host. If you want to put a group as a child of another group you need to use this syntax:

Re: [ansible-project] Configuring Ansible to run play books through a bastion host on aws/ec2

2014-10-29 Thread Michael Peters
Another use case to consider (that I myself have come up against) is configuring the bastion per-host from a dynamic inventory. The servers need to use a different bastion depending on their role and location. On Wed, Oct 29, 2014 at 12:17 PM, erewh0n keith.has...@gmail.com wrote: Thinking on

Re: [ansible-project] Configuring Ansible to run play books through a bastion host on aws/ec2

2014-10-29 Thread Michael Peters
, Michael Peters wrote: Another use case to consider (that I myself have come up against) is configuring the bastion per-host from a dynamic inventory. The servers need to use a different bastion depending on their role and location. On Wed, Oct 29, 2014 at 12:17 PM, erewh0n keith@gmail.com

Re: [ansible-project] ansible_ssh_user and ansible_ssh_pass in windows.yml

2014-10-29 Thread Michael Peters
It will be the remote nodes. In lots of cases these are all the same (lots of setups have the same management account with the same credentials on the managed nodes). And if you need to specify per-host variables for the remote nodes you can do that as well in your inventory. On Wed, Oct 29, 2014

Re: [ansible-project] Error running ec2.py script

2014-10-23 Thread Michael Peters
Try running the dynamic inventory by itself to see what output is generated. ./ec2.py On Thu, Oct 23, 2014 at 11:32 AM, Bruce Bundy brbu...@gmail.com wrote: I have a freshly installed Ubuntu 14.04 LTS instance running ansible 1.5.4 and python 2.7.6 In general my ansible playbooks are

Re: [ansible-project] Organize the template directory within the roles folder

2014-10-22 Thread Michael Peters
It does, but the path is relative, not absolute. Try (notice missing / prefix on src): template: src=folder1/template1.js dest=/opt/foo On Sun, Oct 19, 2014 at 7:02 AM, Ajay Divakaran ajay.divakara...@gmail.com wrote: Hi all, According to the documentation the template files should sit in

Re: [ansible-project] npm is not a legal parameter at this level in an Ansible playbook

2014-10-22 Thread Michael Peters
Sounds like you're running ansible from a git checkout. If that is the case, you need to make sure your git submodules have been fetched as well since the big ansible git submodule split: See https://groups.google.com/forum/#!msg/ansible-project/TUL_Bfmhr-E/rshKe30KdD8J On Tue, Oct 21, 2014 at

Re: [ansible-project] Need serial at the task level for delegate_to or another solution

2014-10-21 Thread Michael Peters
I agree that it would be nice to have serial on the task level. Until that happens you could break out of your current play with a one task play that does just this but with serial: 1 set. Then go back to another play that doesn't use serial to finish the rest of the tasks. On Mon, Oct 20, 2014

Re: [ansible-project] menu prompts

2014-10-19 Thread Michael Peters
Try embedding new line characters in your prompt string: vars_prompt: name: what is your name? quest: what is your quest? favcolor: what is your favorite color?\n 1) red\n 2) green\n 3) blue On Sat, Oct 18, 2014 at 9:31 AM, Jim McMahon jmcma...@flatworldknowledge.com wrote:

Re: [ansible-project] Prompt question again. Thanks

2014-10-17 Thread Michael Peters
, 2014 12:12 PM, Tiglath te...@tiglath.net wrote: Good rule. Thanks On Wednesday, October 15, 2014 2:16:13 PM UTC-4, Michael Peters wrote: vars_prompt goes on the play level, not the task level. It's not a task and you don't have control over when the prompt happens. It will ask you

Re: [ansible-project] Which statement is true

2014-10-17 Thread Michael Peters
What version of ansible are you running? On Fri, Oct 17, 2014 at 1:45 PM, Tiglath te...@tiglath.net wrote: I added run_once because despite local_action it seems to run once per host but locally. The error below contradicts the documentation. Or so it seems. 1: -- hosts:

Re: [ansible-project] remote_user temp

2014-10-16 Thread Michael Peters
I have provisioning playbooks (AWS) that create the server. They then use add_host to add it to the inventory. When using add_host you can pass other variables along that act just like host_vars that came from the inventory (AFAIK). If you pass the ansible_ssh_user you can set the user that

Re: [ansible-project] syntax error in vars bubstution [ shell module ]

2014-10-15 Thread Michael Peters
for the link. Regards, Olga On Thursday, October 9, 2014 1:33:15 AM UTC+5:30, Michael Peters wrote: Try quoting the templated part. The {{ }} syntax markers mess up the yaml parsing - http://docs.ansible.com/YAMLSyntax.html#gotchas On Wed, Oct 8, 2014 at 3:41 PM, olga osu...@gmail.com

Re: [ansible-project] Prompt question again. Thanks

2014-10-15 Thread Michael Peters
vars_prompt goes on the play level, not the task level. It's not a task and you don't have control over when the prompt happens. It will ask you before the play starts to answer any questions in the prompt. Just a helpful way to think about what can go in the task list: Is it a module? (

Re: [ansible-project] Re: How to skip Role Dependencies?

2014-10-09 Thread Michael Peters
I do this by tagging each dependent role as 'dependent-role' and then use the --skip-tags dependent-role when I need to execute just the top level role (usually only for testing). On Thu, Oct 9, 2014 at 1:11 PM, Chris Arnesen chris.arne...@gmail.com wrote: He just means that sometimes the user

Re: [ansible-project] Ansible Play apt: not happy with installing items: tomcat7 tomcat7-admin on vagrant up | ubuntu 12.0.4 | apt

2014-10-09 Thread Michael Peters
Are you setting sudo to true somewhere else. It's hard to see when you've just shown a portion of playbook. If not and you just need sudo for this task, then you can set it per-task like so: tasks: # TOMCAT 7 ### - name: Install

Re: [ansible-project] Using vars in comparison filters

2014-10-08 Thread Michael Peters
It seems you're trying to double template. If you're inside of the {{ }} markers you don't need further {{ }} templating. Trying something like this: debug: msg=Firmware needs to be updated when: {{ firmware_version_on_server.stdout | version_compare(firmware_version_desired,'') }} On Wed, Oct

Re: [ansible-project] shell commands and escaping characters

2014-10-07 Thread Michael Peters
The command module just takes a simple command. If you need a full shell (for pipes, io redirection, etc) use the shell command. But in this case it's still not going to do what you want. The access variable won't be visible to anything outside of that command so it's essentially worthless. If you

Re: [ansible-project] Re: ignore_errors does not take variable

2014-10-07 Thread Michael Peters
You are setting test_err to the *string* yes, but ingore_errors is looking for a boolean expression. Also, you don't need to using the {{ }} syntax in ignore_errors since it is already using jinja2. Try using the bool filter: - hosts: jump remote_user: deploy gather_facts: yes tasks: -

Re: [ansible-project] Is there a way to make my var less ugly?

2014-10-03 Thread Michael Peters
You can use the set_fact module for that. On Oct 3, 2014 7:03 PM, J Hawkesworth j.r.hawkeswo...@googlemail.com wrote: So I created some tasks in one of my roles today that queries Jenkins to find the latest build of a project and then uses that build number to go get a zip file onto one of my

Re: [ansible-project] Limit number of instances with specific role

2014-09-30 Thread Michael Peters
On Tue, Sep 30, 2014 at 3:14 PM, Michael DeHaan mich...@ansible.com wrote: A nice way to express the above might be to use group ranges: - hosts: specific_group[0:5] Nice, I wasn't aware of this syntax. I've used the longer form when doing something like setting up an elasticsearch cluster

Re: [ansible-project] Limit number of instances with specific role

2014-09-29 Thread Michael Peters
Do you need to do this randomly and then remember which ones were randomly chosen? Or could you just, say, work with the first X in a group? If the latter, you might be able to do something like this (untested) to do the first 3 servers in a specific_group: hosts:

Re: [ansible-project] Re: Parsing ansible_hostname

2014-09-22 Thread Michael Peters
The regex_replace filter is probably what you're looking for. Assuming there are only ever 3 segments separated by a hyphen, and you want the 2nd, something like this would work: {{ ansible_hostname | regex_replace('^[^-]+-', '') | regex_replace('-.*', '') }} On Mon, Sep 22, 2014 at 9:07 AM,

Re: [ansible-project] Best way to clean hosts after changing roles?

2014-09-19 Thread Michael Peters
Removing a role or changing a machine's role is pretty rare. Most people in that situation would just shutdown that vm and spin up another with the new role. If you aren't running virtual machines then I'd suggestion having a separate playbook called something like remove-role-X.yml where X is

Re: [ansible-project] Best practices with app/database dependencies

2014-09-18 Thread Michael Peters
I prefer to have my application role depend on my database role and then have my application role setup the things it needs like users and databases. That way my database role is re-usable for other applications have their own database and user needs. On Thu, Sep 18, 2014 at 10:13 AM, Strahinja

Re: [ansible-project] Howto access 'exists' from a register: var which has results?

2014-09-15 Thread Michael Peters
It should be repos_extra_installed.results[0].stat.exists. It's more complicated because you're doing a with_items on the task that does the register. So each item in that list will have a separate entry in the repos_extra_installed.results list. On Sat, Sep 13, 2014 at 2:15 AM, Patrick

Re: [ansible-project] Bringing cohesion to ec2_facts and EC2 inventory plugin

2014-09-13 Thread Michael Peters
This is something I've thought about too. The variable naming mismatch has caused me some headaches as well as the issue of trying to load all of the information that the EC2 dynamic inventory pulls for newly provisioned machines. Would be nice if I could add_host and ec2_facts without having to

Re: [ansible-project] Setting host vars programmatically with dynamic inventory

2014-09-12 Thread Michael Peters
You could modify your dynamic inventory. I think in the past it's been said that the ec2.py, etc are starting points for your own dynamic inventory scripts. This way you can do what you want with your ec2_tag_* variables and makes it easier when part of your infrastructure isn't even on EC2. On

Re: [ansible-project] Strange thing with Jinja2 expressions evaluation

2014-09-12 Thread Michael Peters
That's a pretty old version of ansible. I suspect that the regex_replace filter didn't exist then. You should definitely upgrade since it works on 1.7.1. On Fri, Sep 12, 2014 at 10:07 AM, Andrew Pashkin andrew.pash...@gmx.co.uk wrote: With this playbook: - name: test playbook hosts:

Re: [ansible-project] Change current directory before tasks are run

2014-09-12 Thread Michael Peters
Does the chdir argument to raw work? raw: /usr/sbin/lsof /afs chdir=/ On Fri, Sep 12, 2014 at 12:45 PM, Jesse DeFer jde...@gmail.com wrote: I am trying to create a playbook to unmount an AFS mounted home directory, but I can't unmount it because the user running ansible has open files

Re: [ansible-project] Are group_vars re-evaluated for freshly provisioned EC2 instances with tags matching group names?

2014-09-05 Thread Michael Peters
You can pass variables into add_host, so if you have the information you need you can pass it along with the name you need. For instance: add_host: name: blah groups: db ec2_tag_Name: blah ec2_tag_Environment: staging I believe they will be considered inventory host_vars (and

Re: [ansible-project] YAML formatting best practices - tasks with many params

2014-08-28 Thread Michael Peters
On Thu, Aug 28, 2014 at 12:34 PM, Patrick Heeney patrickhee...@gmail.com wrote: Even with the widest screens available it is very difficult to read everything on one line. For version control as mentioned it is also a lot easier to break it up. Take for example this playbook of mine:

Re: [ansible-project] Ansible organization

2014-08-22 Thread Michael Peters
This is what host_vars are for. You can set them as part of your inventory file (or dynamic inventories can set them too) or you can have host_vars files which data for each (similar to group_vars). See http://docs.ansible.com/playbooks_variables.html and

Re: [ansible-project] Weird set_fact boolean problem

2014-08-14 Thread Michael Peters
false and it's important the word doesn't get auto-converted into a boolean. On Wed, Aug 13, 2014 at 1:43 PM, Michael Peters michael00pet...@gmail.com wrote: Also, isn't it weird the with the variable foo set to string false both when: foo and when: not foo evaluate to false? On Wed, Aug 13

Re: [ansible-project] Weird set_fact boolean problem

2014-08-14 Thread Michael Peters
that way. Can you share a playbook that reproduces this? On Thu, Aug 14, 2014 at 9:08 AM, Michael Peters michael00pet...@gmail.com wrote: Yes, I realize the difference between a string and a boolean. But I've never seen a system where foo and not foo evaluate to the same thing. On Thu

Re: [ansible-project] Weird set_fact boolean problem

2014-08-14 Thread Michael Peters
, Aug 14, 2014 at 9:42 AM, Michael Peters michael00pet...@gmail.com wrote: Sure: test.yml --- - hosts: 127.0.0.1 connection: local tasks: - set_fact: foo=false - command: ls / when: foo - command: ls / when: not foo Executed like ansible-playbook -i '127.0.0.1

Re: [ansible-project] Weird set_fact boolean problem

2014-08-13 Thread Michael Peters
is: when: not foo|bool On Wednesday, August 13, 2014, Michael Peters michael00pet...@gmail.com wrote: Before I file a ticket, I just want to make sure I'm not doing anything wrong. BTW, this is a simplified example to reproduce the problem, not what I was actually trying to do. I have

Re: [ansible-project] Weird set_fact boolean problem

2014-08-13 Thread Michael Peters
, Aug 13, 2014 at 10:31 AM, Michael Peters michael00pet...@gmail.com wrote: Is there a way to use set_fact to force it to use a real boolean instead of the string? In the real playbook other tasks and includes further down don't care where the var came from and I'd rather not have to alter

Re: [ansible-project] Weird set_fact boolean problem

2014-08-13 Thread Michael Peters
Also, isn't it weird the with the variable foo set to string false both when: foo and when: not foo evaluate to false? On Wed, Aug 13, 2014 at 1:42 PM, Michael Peters michael00pet...@gmail.com wrote: Thanks, this works. I was under the impression that the 2 syntax variants (yaml vs key-value

Re: [ansible-project] Is there a Pattern for having one machine in a cluster perform an action?

2014-08-08 Thread Michael Peters
Ansible 1.7 added the new run_once keyword so that a given action will only run once for that host list. On Fri, Aug 8, 2014 at 10:08 AM, Guy Matz guym...@gmail.com wrote: Hi! I have a few django servers . . . I would like to run a syncdb in my playbook, but only need/want one of the django

Re: [ansible-project] Templated file used as variable?

2014-08-08 Thread Michael Peters
I don't know if you know this, but variables can themselves be templated. You can do this in a set_fact or even in a variable file (group_vars, host_vars, var_files, etc). For instance: set_fact: foo={% if yada %}{{ (blah + baz) / 100 }}{% else %}{{ fiddly * 100 }}{% endif %} Or in a var file:

Re: [ansible-project] How to escape a variable?

2014-08-08 Thread Michael Peters
Probably not the best way, but you could use a string inside of the jinja templating - name: obtain image id local_action: shell docker inspect --format={{ '{{.Id}}' }} {{ docker_image_name }} | cut register: docker_image_id On Fri, Aug 8, 2014 at 1:04 PM, Vijay Korapaty

[ansible-project] run_once and serial

2014-07-25 Thread Michael Peters
I'm testing out the new run_once feature and overall it's working great. But I then tried it in an upgrade playbook using serial. The task is no longer run just once per-play, it's run once per-host-group. So for a serial of 2 in a target group of 10 servers it's run once per pair, so 5 times.

Re: [ansible-project] What is the best way of restarting services that are part of a cluster without taking the cluster down?

2014-07-24 Thread Michael Peters
On Thu, Jul 24, 2014 at 7:00 AM, Michael DeHaan mich...@ansible.com wrote: You could also set a simple play like this, which would probably be cleaner: - hosts: blarg serial: 1 tasks: - pause: seconds={{ n }} - service: name=foo state=restarted Is there a way to do something

Re: [ansible-project] autoscaling_group + add_host == not possible?

2014-07-24 Thread Michael Peters
If I understand correctly, this is what add_hosts is for. After you've dynamically created a host you can add it to a group and then in a subsequent play include a role that would configure that group. Is that what you're looking for? On Thu, Jul 24, 2014 at 9:43 AM, Guy Matz guym...@gmail.com

Re: [ansible-project] What is the best way of restarting services that are part of a cluster without taking the cluster down?

2014-07-24 Thread Michael Peters
On Thu, Jul 24, 2014 at 11:54 AM, David Reagan jer...@gmail.com wrote: So, handlers seem like they are just special tasks that you can call with the notify option. If that's the case, couldn't I just make a handler that uses the at module instead of the service module? Actually, I think I've

Re: [ansible-project] Best way to add reusable provisioning steps to existing roles

2014-07-22 Thread Michael Peters
I actually tackle this another way. I write provisioning playbooks (not a role) that will create the server on the provider. And then when it's finished, run some bootstrapping steps. After that is done, use add_host to add it to the right group and then include the role-level playbook. This way

Re: [ansible-project] Playbook organization with var files

2014-07-18 Thread Michael Peters
On Thu, Jul 17, 2014 at 9:38 PM, Michael DeHaan mich...@ansible.com wrote: This is not because of cwd at all, but because of the playbook basedir. You're right that the cwd isn't causing the difference in behavior. I was trying to point out that it seems weird that playbooks behave differently

Re: [ansible-project] Playbook organization with var files

2014-07-18 Thread Michael Peters
I don't want to change the current behavior, just add to it. This wouldn't stop using the playbook basedir as the primary place to look. But you're right, it would change the execution based on where you execute the command. But only if you were using the cwd feature. This wouldn't stop using the

Re: [ansible-project] Playbook organization with var files

2014-07-18 Thread Michael Peters
So how do you solve loading group_vars automatically? Or if you don't, how do you resolve the differences between how group_vars are treated when automatically loaded vs loading them explicitly with vars_files ? That's the issue that led me on this wild chase. On Fri, Jul 18, 2014 at 10:46 AM,

Re: [ansible-project] Playbook organization with var files

2014-07-17 Thread Michael Peters
...@ansible.com wrote: I'd consider using roles and just making your role path configurable, which would still make it easy to keep all your plays in whatever location you like. (You could even keep roles in different repos, etc) On Wed, Jul 16, 2014 at 5:57 PM, Michael Peters michael00pet

Re: [ansible-project] Playbook organization with var files

2014-07-17 Thread Michael Peters
files sitting at the top level if I did it that way. And this project is just getting started. Using the cwd as an extra path lookup seems like a pretty easy way to add this capability without any problems that I can see. On Thu, Jul 17, 2014 at 9:21 AM, Michael Peters michael00pet...@gmail.com

[ansible-project] mysql_* modules defaults from my.cnf

2014-07-17 Thread Michael Peters
Right now the various mysql_* modules will pull default connection information from the ~/.my.cnf file. This is especially important to make things repeatable especially when the server is newly provisioned and insecure. But it doesn't use the socket information in the ~/.my.cnf file. Instead if

[ansible-project] Playbook organization with var files

2014-07-16 Thread Michael Peters
I'm looking for advice about how to organize my playbooks. Not so much the content as their structure on the file system. Currently I have all of my configuration management (role-level) playbooks at the top level with things like common.yml, app.yml, db.yml, etc. These correspond directly to

Re: [ansible-project] How to use hosts listed in a group in a template, excluding the current host.

2014-07-14 Thread Michael Peters
Try something like this: {% for svr in groups.ntp_servers %} {% if not svr == inventory_hostname %} peer svr {% endif %} {% endfor %} On Mon, Jul 14, 2014 at 4:30 AM, John Wang john.wang@gmail.com wrote: I'm new to Ansible and want use it to configure a NTP service. here is my

Re: [ansible-project] Re: shell/command json output into variables

2014-07-14 Thread Michael Peters
Would it be possible to have an extra option to command to so that it can work similar to the uri module's return_content option? That way results that are registered would be the same except for an extra json key with the structured data. Not sure what to call it as return_content isn't

Re: [ansible-project] Using register with exact_count when launching an instance on EC2

2014-07-09 Thread Michael Peters
Try using debug on ec2_info to see what it contains. It seems that instances is coming back with a list of strings and not a list of objects like you thought. On Wed, Jul 9, 2014 at 4:50 AM, Ofer Herman ofe...@gmail.com wrote: Hi, I'm using exact_count when creating an instance on EC2, when

Re: [ansible-project] AWS EC2 instance create via Ansible IAM Roles instance_profile_name UnauthorizedOperation: Error

2014-06-26 Thread Michael Peters
On Thu, Jun 26, 2014 at 1:21 AM, Faisal Ali Rabbani rabb...@zoniversal.com wrote: Obviously I have not shared credentials this is the policy of role, which has full access of ec2. Sorry, I wasn't clear. Are you showing the policy rules of the role being created or the one doing the creation?

Re: [ansible-project] Using a variable inside a jinja loop

2014-06-24 Thread Michael Peters
When inside the {% %} part you are inside of jinja and don't need special syntax to tell it that your using jinja variables. Something like this should work: {% for host in groups[deploy_env + '-web'] %} server {{ host }} {{ host }}:80 {% endfor %} On Tue, Jun 24, 2014 at 10:48 AM, Claus

Re: [ansible-project] Re: Accessing ec2.py dynamic inventory variables in templates

2014-06-20 Thread Michael Peters
I've added normalize_groups as part of https://github.com/ansible/ansible/pull/7867 On Thu, Jun 19, 2014 at 5:35 PM, Michael DeHaan mich...@ansible.com wrote: That seems reasonable to me. On Thu, Jun 19, 2014 at 4:33 PM, Michael Peters michael00pet...@gmail.com wrote: I thought about

Re: [ansible-project] Possible bug in repeated runs of ec2_group module with wide-open rule

2014-06-19 Thread Michael Peters
it's trying to create a default ingress rule which will also use -1's for the same fields, but for some reason it's not seeing you adding that rule yourself. On Wed, Jun 18, 2014 at 4:58 PM, Michael Peters michael00pet...@gmail.com wrote: I have the following as part of a playbook

Re: [ansible-project] Trouble with using variables for ec2 tags

2014-06-19 Thread Michael Peters
18, 2014 at 3:09 PM, Michael Peters michael00pet...@gmail.com wrote: I'm trying to create a VPC with certain tags which are derived from variables. I feel like I can't find the right YAML/Jinja/whatever syntax to make it work though. At first I tried setting them in the resource_tags directly

Re: [ansible-project] Re: Accessing ec2.py dynamic inventory variables in templates

2014-06-19 Thread Michael Peters
You can pull it from the hostvars dictionary with something like hostvars[inventory_hostname]['ec2_tag_elasticbeanstalk_environment-name'] On Thu, Jun 19, 2014 at 12:06 PM, Roger Hunwicks roger.hunwi...@gmail.com wrote: After further investigation... When the playbook runs, on that task

Re: [ansible-project] Re: Accessing ec2.py dynamic inventory variables in templates

2014-06-19 Thread Michael Peters
, so it's easy to fix with a convention. On Thu, Jun 19, 2014 at 12:28 PM, Michael Peters michael00pet...@gmail.com wrote: You can pull it from the hostvars dictionary with something like hostvars[inventory_hostname]['ec2_tag_elasticbeanstalk_environment-name'] On Thu, Jun 19, 2014

Re: [ansible-project] Re: mysql_db state=import only once

2014-06-11 Thread Michael Peters
I've wanted to create a mysql_query module that would probably help with a lot of things like this. It could execute an arbitrary query and then you could register the results. Would make it easier than having to manipulate mysql command line stdout since you could use structured data. I just

Re: [ansible-project] Best practice for referring to other host IPs

2014-06-04 Thread Michael Peters
But it gets more unwieldy if you're using roles. If my app role needs to have the IPs for the databases I just have to hope that the playbook that ends up running the tasks in my play have gathered all the facts from those other systems. It gets even more action-at-a-distance when your role is a

Re: [ansible-project] enumerate elasticache/redis instances

2014-06-02 Thread Michael Peters
If you have a redis group of servers you can do something like: {% for host in groups['redis'] %} {{ hostvars[host].ansible_default_ipv4.address }} {% endfor %} Which will print the IP address of that host in the template file. On Mon, Jun 2, 2014 at 9:45 AM, Damjan Georgievski

Re: [ansible-project] include another role's variables without running it's tasks?

2014-05-28 Thread Michael Peters
On Wed, May 28, 2014 at 7:58 AM, Michael DeHaan mich...@ansible.com wrote: I'd configure your backup tool to indicate what paths should be backed up. That's actually his initial question. Apache knows where to serve sites from based on that role's (or groups) variables. Now his backup tool

Re: [ansible-project] SSH inside a task

2014-05-22 Thread Michael Peters
On Wed, May 21, 2014 at 6:21 PM, Michael DeHaan mich...@ansible.com wrote: Don't do this :) Use Ansible and if need be, configure jumphosts, or whatever, but Ansible shouldn't ever *NEED* to call ssh. I agree it shouldn't be done in general, but I'm interested to see how you would have

  1   2   >