Re: [ansible-project] Ansible but with Python instead of YAML

2019-02-01 Thread Josh Smift
YAML is great; I was confused at first because I thought it was a "markup language" like HTML, but it's just a way to represent data structures. It's not a programming language, though. If you want to write your system configuration in a programming language (Python, in this case :^), you might

[ansible-project] Iterating over parts complex data structures while still referring to other parts of the structure

2019-06-10 Thread Josh Smift
I have a data structure like this: part: eyes: where: faces colors: - blue - brown - green hair: where: heads colors: - black - blond - brown - red toenails: where: feet colors: - pink - red - teal I want to

Re: [ansible-project] Iterating over parts complex data structures while still referring to other parts of the structure

2019-06-11 Thread Josh Smift
subelements([1, 'colors']) }}" > loop_control: > label: "{{ item.0.0 }}_{{ item.1 }}" > > From there, you should be able to extrapolate to meet your specific needs, > potentially using the template module, to write out the files. > > On Mon, Jun

Re: [ansible-project] Help wanted: "Including" playbooks for a "Playbook of Playbooks"

2019-07-19 Thread Josh Smift
We want to do this as a check that all of our hosts are in synch; we have a playbook per system type, and we don't want the check to fail if e.g. the only host of a given type is down (which would thus be a 100% failure of that playbook). We do it like this: - import_playbook: thing1.yml - imp

[ansible-project] Re: Block/Always Always section not executing.

2018-02-01 Thread Josh Smift
There's a bunch of issues about this; https://github.com/ansible/ansible/issues/20736 is one, but I think maybe isn't yours. If you search there for "block always", though, you'll probably find some stuff. (I also had to reply to this, since I used to also be Josh Smith. But a different one. :

Re: [ansible-project] Is it possible to avoid aborting a play if all hosts in a serial batch fail?

2018-03-01 Thread Josh Smift
This is a good metaphor, and I've never understood why `serial` works this way. We've repeatedly had situations where we want to do things on a few hosts at a time, and continue even if one batch of them fails -- especially if the batch size is 1 -- and there's just no way to do that. I underst

Re: [ansible-project] Is it possible to avoid aborting a play if all hosts in a serial batch fail?

2018-03-01 Thread Josh Smift
On Thursday, March 1, 2018 at 8:59:10 AM UTC-5, Josh Smift wrote: > > I understand the use cases for wanting to fail if all your batches fail: > Oops, I misspoke here: I meant "the use cases for wanting to fail the whole play if all the hosts *in one batch* fail. To switch back

[ansible-project] Re: Cannot install ansible tools or development modules on windows as of 2.4

2018-03-19 Thread Josh Smift
This may be a dumb question, but can you develop on a remote system too? My company also doesn't support Linux workstations/laptops, but I do all my Ansible development work on remote Linux hosts anyway. On Monday, March 19, 2018 at 10:53:46 AM UTC-4, Bill Brothers wrote: > > As has been asked a

Re: [ansible-project] Re: Absurd run_once behavior, skipping entirely if first node fails a when test

2018-03-19 Thread Josh Smift
My use case involved roles. I had something like - hosts: web:app:db roles: - role: myrole when: color == "blue" In the role, there was a task that ran on localhost (via delegate_to), but only once (via run_once) for the whole batch of hosts. Everything worked fine, except that if t

Re: [ansible-project] Re: Absurd run_once behavior, skipping entirely if first node fails a when test

2018-03-20 Thread Josh Smift
ndition is logical-AND-ed with any other conditions on the task, such that if the task has conditions that cause it to get skipped on the first host in inventory, this condition will cause it to get skipped on all the other hosts as well. On Tuesday, March 20, 2018 at 1:13:58 AM UTC-4, flowerysong w

[ansible-project] Re: Help me please. How can I get the output of the command?

2018-05-14 Thread Josh Smift
Why are you setting "verbosity: 3"? According to http://docs.ansible.com/ansible/latest/modules/debug_module.html, that means "if you set to 3 it will only run debug when -vvv or above". That's causing Ansible to skip the task, thus the message you're seeing ("Verbosity threshold not met"). Re

[ansible-project] Re: Help me please. How can I get the output of the command?

2018-05-16 Thread Josh Smift
but it gives me back the same information. > <> > The problem is that vmware_vm_shell module does not return the output of > the command. > > > > El martes, 15 de mayo de 2018, 3:40:26 (UTC+2), Josh Smift escribió: >> >> Why are you setting "verbosity: 3&

Re: [ansible-project] Speeding up very large playbooks

2018-08-07 Thread Josh Smift
Even with Mitogen's current limitations, it cut run times about in half for our "do everything to all the hosts" playbook, which hits about 200 hosts with 1600 tasks in our biggest environment. On Tuesday, August 7, 2018 at 7:45:38 AM UTC-4, David Wilson wrote: > > Hi, > > Just to note Mitogen s

[ansible-project] template module when dest is a directory

2017-05-09 Thread Josh Smift
If you use the template module and the dest parameter specifies a directory, the module creates a file in the directory with the same name as the value of the src parameter. However, if you then change the source contents, and run ansible-playbook with --check --diff, it says that there's a change

Re: [ansible-project] template module when dest is a directory

2017-05-09 Thread Josh Smift
JBS> https://docs.ansible.com/ansible/template_module.html doesn't say JBS> that you can specify a directory as the value of the dest parameter. JBS> Should that work? JBS> JBS> If it should work to specify a directory, should 'diff' work as well? JBS> JBS> I can create a bug report, but I wasn't s

Re: [ansible-project] template module when dest is a directory

2017-05-09 Thread Josh Smift
https://github.com/ansible/ansible/issues/24413 -- thanks! -Josh (j...@care.com) (apologies for the automatic corporate disclaimer that follows) This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED

[ansible-project] Updating an IAM cert

2017-05-19 Thread Josh Smift
We uploaded an IAM cert to AWS, and now need to update the certificate (the contents). On the theory that a lost of this stuff is idempotent, I thought this task, which we used to upload it in the first place, would work to update it as well: - name: configure IAM certificates iam_cert:

[ansible-project] when statements should not include jinja2 templating delimiters

2017-05-23 Thread Josh Smift
DC> In this specific case I could get away with dropping the final clause DC> of the `when` check, but does anybody have an idea how to refactor DC> this to avoid the warnings in future? I get the feeling I'm missing DC> some very obvious pattern here. Just drop the Jinja delimiters: Since 'when'

[ansible-project] Variable namespacing

2017-06-27 Thread Josh Smift
BM> When wanting to namespace variables in a role, is it typical to use a BM> hash, or a prefix? Is there a best practice for this? There are pros and cons either way. Off the top of my head, using a hash lets you iterate over it easily, and IMHO looks nicer; but you can't (as far as I know) add e

[ansible-project] [WARNING]: when statements should not include jinja2 templating delimiters such as {{ }} or {% %}.

2017-06-29 Thread Josh Smift
ta> task: ta> - include: lvm.yml ta> when: ansible_devices.{{ raw_disk }}.partitions|length == 0 The shortcut a.b.c.d notation doesn't let you distinguish between literals and variables. Try the more Pythonic when: ansible_devices[raw_disk]['partitions']|length == 0 and see if that does

Re: [ansible-project] do post_tasks execute when a role fails?

2017-09-03 Thread Josh Smift
Does 'meta: clear_host_errors' help in this situation? http://docs.ansible.com/ansible/latest/playbooks_error_handling.html#resetting-unreachable-hosts only mentions this as affecting unreachable hosts, but http://docs.ansible.com/ansible/latest/meta_module.html mentions that it clears the failed s

[ansible-project] ec2_group is not idempotent

2017-09-03 Thread Josh Smift
Is this the same problem as https://github.com/ansible/ansible-modules-core/issues/1068 ? It looks from your output like it might be: 138.68.160.0/20, TCP, from port: 22, to port: 22, ALLOW" already exists fatal: [localhost]: FAILED! => {"changed": false, "error": {"code": "InvalidPermission

Re: [ansible-project] Re: Are Tags from the dark side ???

2017-11-22 Thread Josh Smift
As a new feature, you could imagine being able to put something like tags: - javajdk into .../roles/javajdk/meta/defaults.yml, but I don't think there's currently a way to tell a role "add this tag to all your tasks", inside the role itself, other than adding the tag explicitly to all the t

[ansible-project] Run once with when statement causes only skipped action to run

2017-12-08 Thread Josh Smift
There's a bunch of tickets about run_once and skipped hosts; https://github.com/ansible/ansible/issues/19966 is my personal favorite. -Josh (j...@care.com) (apologies for the automatic corporate disclaimer that follows) This email is intended for the person(

Re: [ansible-project] Run once with when statement causes only skipped action to run

2017-12-08 Thread Josh Smift
> Weirdly, when I try to create an in-memory host group using when and > add_host the task only gets executed one time (on a skipped host). I > don't have run_once on this task so I'm not sure why all my nodes aren't > executing it. Any ideas? add_host is implicitly run_once; there's a note about

[ansible-project] Idempotent fetching of files by URL

2018-01-11 Thread Josh Smift
There doesn't seem to be a way to fetch a file by URL that meets both of these criteria: - When run without --check, replaces the dest file with the contents of the source file if and only if they're different. - When run with --check, correctly tells you whether anything would change if you ru

Re: [ansible-project] Idempotent fetching of files by URL

2018-01-13 Thread Josh Smift
Yar; and also, force: no means that it doesn't even check if the file has changed, whether in --check mode or not -- if the file exists, it doesn't do anything, even if the contents are wrong. -- You received this message because you are subscribed to the Google Groups "Ansible Project" group.

[ansible-project] Re: Idempotent fetching of files by URL

2018-01-16 Thread Josh Smift
It turns out that unarchive with a .zip file basically works -- except that on our Ubuntu 16.04 systems, for some reason, it deals with timezones in some bizarre way that I can try explain but won't bother unless anyone really wants to know. As long as the zip files were built in the same timez

[ansible-project] Re: Configuration Drift

2023-06-27 Thread Josh Smift
Having Ansible just push out changes as soon as they're merged to `main` (or whatever) is pleasantly CI/CD like, and means that you can solicit pull requests from interested parties who may not have privs to run Ansible, and not have to push out their changes by hand once the PRs are merged. Bu

[ansible-project] Unified inventory

2014-07-25 Thread Josh Smift
Our inventory comes from multiple sources, a couple dynamic and one static. Ansible itself can pull them all together into a unified inventory, but we'd like to transform the dynamic sources on the way in, without having to hack the scripts that produce them, so we can use the stock versions from .

[ansible-project] lib/ansible/module_utils/known_hosts.py requires hashlib

2014-07-25 Thread Josh Smift
Between Ansible 1.5.3 and 1.6.6, lib/ansible/module_utils/known_hosts.py added from hashlib import sha1 which doesn't work on target hosts who only have Python 2.4. The 'git' module uses this, and produces this stacktrace on a target RHEL 5 system: Traceback (most recent call last):

Re: [ansible-project] lib/ansible/module_utils/known_hosts.py requires hashlib

2014-07-25 Thread Josh Smift
Heh, I didn't think to check this before I'd sent mail, but there's actually already a fix for this in devel, in https://github.com/ansible/ansible/commit/60451c20ab0cb8293a1ba51b48c600819a676626 -- it just hasn't made it into a release yet, I guess. -Josh (

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

2014-08-25 Thread Josh Smift
MD> But Ansible playbooks are not Python, nor do we assume folks will need MD> to know Python. Sure; I think that was just an example of a coding style that recommends short lines (along with the Linux kernel coding style). FWIW, I think the diff argument is pretty compelling: I find it a lot eas

[ansible-project] with_first_found and templates

2014-09-03 Thread Josh Smift
We've got a task like this: - name: template TrustedHosts template: dest=/etc/opendkim/TrustedHosts src={{ item }} backup=yes with_first_found: - TrustedHosts.{{ stack }} - TrustedHosts.default There are three hosts that use the playbook this is in, and when Ansible get

Re: [ansible-project] with_first_found and templates

2014-09-03 Thread Josh Smift
MD> Can you please file a bug on this one so we can look at it? Done: https://github.com/ansible/ansible/issues/8879 (from my personal account, I don't have a work-related Github account at the moment). Thanks! -Josh (j...@care.com) This email is intended

[ansible-project] Only show output for changed things?

2014-09-04 Thread Josh Smift
Is there a way to tell Ansible to only show output for things that have changed? We've got playbooks that include roles and run dozens of tasks, and often want to check to see what's going to happen before we actually run them (because we share some common code between a couple of sites, each of wh

Re: [ansible-project] Only show output for changed things?

2014-09-05 Thread Josh Smift
MD> Ansible will print everything, because it's important to know when MD> things come back. In our usage, we frequently don't care at all when things come back: We have a playbook that we know is going to take several minutes to run (dozens of tasks on dozens of hosts), so we fire it off, go do s

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

2014-09-05 Thread Josh Smift
MD> Inventory script gets evaluated at inventory host time, so it's always MD> a good idea to use "add_host" to explicitly add them in memory to MD> those specific groups. Is there a way to add variables for them, too? For example, if you want to use inventory variables like ec2_tag_ in your tasks

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

2014-09-05 Thread Josh Smift
MD> What version of ansible are you running? 1.6.6 at work, 1.7.1 at home. -Josh (j...@care.com) This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distri

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

2014-09-05 Thread Josh Smift
MD> What version are you running when you are testing that group_vars/ is MD> not available to hosts added with the add_host module? 1.7.1 -- but it's not that variables from group_vars aren't available, it's that host-specific ec2_tag_* variables that come from the ec2.py dynamic inventory script

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

2014-09-05 Thread Josh Smift
JBS> 1.7.1 -- but it's not that variables from group_vars aren't JBS> available, it's that host-specific ec2_tag_* variables that come from JBS> the ec2.py dynamic inventory script aren't available. Ah, sorry, I now see that this thread was in fact originally about group_vars. I segued off into ho

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

2014-09-12 Thread Josh Smift
MP> You can pass variables into add_host, so if you have the information MP> you need you can pass it along with the name you need. For instance: MP> MP> add_host: MP> name: blah MP> groups: db MP> ec2_tag_Name: blah MP> ec2_tag_Environment: staging MP> MP> I believe they will be

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

2014-09-12 Thread Josh Smift
CM> Basically, assuming this were possible somehow, it's what I want to do CM> (note the same dict key on both sides of assignment): CM> CM> hostvars[host].zookeeper_myid = hostvars[host].ec2_private_ip_address This seems like the thing that someone else helped me figure out how to do, e.g. I now

Re: [ansible-project] Which user to run plays?

2014-09-18 Thread Josh Smift
Keep in mind is that there are two things here: The user you run Ansible as, and the remote user that Ansible acts as on the target systems. One thing you can do is set remote_user to 'ansible', and then put your admins' public keys in the 'ansible' user's authorized_keys file on the target systems

[ansible-project] with_flattened: list vs lookup('flattened',list-of-lists)

2014-09-24 Thread Josh Smift
We have a playbook like this: - hosts: localhost gather_facts: false vars: produsers: [chris, dana] stgusers: [pat, sandy] allusers: [alex, andy, chris, dan, dana, jamie, pat, sandy, terry] tasks: - name: show authorized debug: msg={{ item }}

Re: [ansible-project] with_flattened: list vs lookup('flattened',list-of-lists)

2014-09-24 Thread Josh Smift
MD> However, what's happening is "item" is the only thing that decides MD> what you are looping over. Right; the thing that we wanted to do here, if I were expressing it in Python-like pseudocode, would be something like: for user in allusers: if user in itertools.chain(produsers, stgusers)

[ansible-project] Hiding varibles in with_items

2014-10-02 Thread Josh Smift
We want to with_items over a set of variables with private data in them, like AWS keys. This causes us to get output like TASK: [ourtask | template .s3cfg] changed: [host1] => (item={'access_key': 'my-access-id', 'secret_key': 'my-secret-key', 'name': 'me'

Re: [ansible-project] Hiding varibles in with_items

2014-10-02 Thread Josh Smift
MM> I would recommend setting 'no_log: True' on your task. Then the contents MM> of the items will be suppressed. We do this with 'secrets' and with tasks MM> that loop over data sets that have overly large strings or values. MM> MM> There is some additional information at: MM> MM> http://docs.an

Re: [ansible-project] apt module doesn't install module with a 'when' condition

2014-10-02 Thread Josh Smift
JC> Yes, here's a simple reproducer: JC> JC> - hosts: localhost JC> gather_facts: no JC> vars: JC> test: ['a', 'b'] JC> tasks: JC> - shell: echo -e 'a\nb\nc' JC> register: result JC> - debug: var=result JC> - name: do it JC> yum: name="{{item}}" JC> with_items: result.st

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

2014-11-17 Thread Josh Smift
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 ground. I've got a playbook that provisions a new Rackspace Cloud host, and then includes a role specific to that type of host. In that role, there are some templates

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

2014-11-17 Thread Josh Smift
MP> No, but you can add the machine to the necessary groups when you use MP> add_host after its created. Yeah, I can mostly do this; the tricky thing is that there are some derived groups that the host gets added to based on logic in the dynamic inventory script. I could in theory duplicate that l

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

2014-11-17 Thread Josh Smift
JBS> This email is intended for the person(s) to whom it is addressed and JBS> may contain information that is PRIVILEGED or CONFIDENTIAL. KEJ> (sigh). Really??? Really?? Surely nobody uses that legalese rubbish KEJ> noise anymore? Surely not. I can't explain where that text came from. Probably n

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

2014-11-18 Thread Josh Smift
Bleah, so the latest snag I've run into is that our dynamic inventory script sets some host variables, including some that are based on the derived groups that it comes up with, and of course *those* aren't available even after adding the host to a group during a run, because they're not "group var

[ansible-project] rax_meta module only supports complete replacement?

2014-11-18 Thread Josh Smift
It looks like the rax_meta module only supports the complete replacment of the existing metadata with a new struct of metadata. Is that right, or am I overlooking something? (I'm using 1.7.2, but it looks like the current version at https://github.com/ansible/ansible-modules-core/blob/devel/cloud/r

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

2014-11-18 Thread Josh Smift
JBS> There's not a way to have a dynamic inventory script create group JBS> variables, is there? It's all just host variables? SvG> That is certainly possible: SvG> http://docs.ansible.com/developing_inventory.html#script-conventions Oooh, that is super, and after modifying our custom dynamic inv

Re: [ansible-project] 'copy' operation on remote host?

2014-11-20 Thread Josh Smift
MP> Two shell tasks with "tar -c" and "tar -x"? If you want to preserve permissions; or you could run a command that pipes one to the other; or you could run a command that runs an rsync preserving permissions. If you want to copy a file and *change* the permissions, that could be harder. Maybe t

[ansible-project] Support for Route 53 ListResourceRecordSets?

2014-11-25 Thread Josh Smift
http://docs.ansible.com/route53_module.html doesn't mention being a way to list all the records in a zone; http://docs.aws.amazon.com/Route53/latest/APIReference/API_ListResourceRecordSets.html talks about an API call to do it. Does Ansible support this in a way other than what's on that route53_m

[ansible-project] Nested variables and regex_replace()

2014-12-02 Thread Josh Smift
I have some variables like 'service', which can be "abc" or "xyz", and 'site', which can be "bos" or "sfo", on different hosts. I have hosts whose FQDNs are like service-site-thing-N.site.service.care.com, which have those those variables set accordingly, in a group like 'things'. My use case is t

Re: [ansible-project] Nested variables and regex_replace()

2014-12-02 Thread Josh Smift
MM> The problem is that cannot nest jinja brackets inside of brackets. Ah! Right, because brackets mean "Jinja", not just "variable". Still new here. :^) MM> Your following example: MM> MM> {{ ansible_hostname | regex_replace("^{{service}}-{{site}}-", '') }} MM> MM> Should probably be: MM> MM>

Re: [ansible-project] Ansible Week

2014-12-03 Thread Josh Smift
YvB> Changed_when will report the task never as changed right? My goal is YvB> to to use "when", but to report it as "ok" or "changed", but never as YvB> "skipped". Yeah; I can think of use cases for all of "I don't want to see skipped things", "I don't want to see ok things", and "I don't want to

Re: [ansible-project] Group vars override role vars?

2014-12-03 Thread Josh Smift
MH> I’m not sure why I’d ever want to use vars/ then. Sure I could be MH> convinced of a use-case A use case I've seen, which doesn't seem all that uncommon, is when you want to use a given role with multiple inventories, each of which has its own inventory/group/host vars structure. Putting t

[ansible-project] Patterns and precedence

2015-02-10 Thread Josh Smift
http://docs.ansible.com/intro_patterns.html shows webservers:dbservers:&staging:!phoenix as an example of a combination of unions and intersections, and says that this means all machines in the groups `webservers' and `dbservers' are to be managed if they are in the group `staging' also, b

Re: [ansible-project] ansible-vault edit changing perms and group

2015-02-17 Thread Josh Smift
One thing about SSH keys is that they're generally unique to one person (or one account anyway). I feel like there's a not-uncommon use case for wanting your sysadmins (in a Unix group 'sysadmin', say) to be able to access Ansible vault files as themselves (i.e. without sudo), which would be easy i

[ansible-project] extra_create_args for rax module

2015-02-20 Thread Josh Smift
We want to use the rax module to create instances of the "Memory" flavor, and are getting an error like msg: Policy doesn't allow memory_flavor:create:image_backed to be performed. when we try. https://github.com/chef/knife-rackspace/issues/91 looks like a similar issue for Chef, where they con

Re: [ansible-project] extra_create_args for rax module

2015-02-25 Thread Josh Smift
MM> Ansible 1.8 does not support boot from volume for rax servers. 1.9 MM> will however support this properly: MM> MM> https://github.com/ansible/ansible-modules-core/pull/798 MM> https://github.com/ansible/ansible/pull/10259 MM> MM> extra_create_args unfortunately doesn't give you full enough cont

Re: [ansible-project] extra_create_args for rax module

2015-02-25 Thread Josh Smift
JBS> I'm playing with a clone of devel, and making some progress, but one JBS> thing we're having trouble with is using rax.py to get our inventory. JBS> I'm using the rax.py from devel, and it seems to be failing with a JBS> pyrax exception: JBS> JBS> pyrax.exceptions.BadRequest: n/a (HTTP 400)

Re: [ansible-project] multi stage and variables

2015-04-20 Thread Josh Smift
BK> But having general variables override specific variables simply does BK> not make any sense. I have seen no argument from the Ansible team that BK> supports this behavior on its merits. Is the issue that general variables override specific variables, or just that there isn't a way to express i

[ansible-project] ec2.py and ansible_ssh_host

2015-12-23 Thread Josh Smift
We use the ec2.py inventory plugin, and vpc_destination_variable = Name in ec2.ini so that our inventory shows the value of the Name tag rather than an IP address. However, we'd like to use the IP address from inventory to actually talk to the host, so that if the name doesn't show up in DNS r

[ansible-project] Re: Correct way to use fail module and negative conditionals

2015-12-23 Thread Josh Smift
FL> - name: check if target server is CentOS 6 or Ubuntu 14 FL> fail: msg='unsupported platform detected!' FL> when: (ansible_distribution != "CentOS" and FL> ansible_distribution_major_version != "6") or (ansible_distribution != FL> "Ubuntu" and ansible_distribution_major_version

[ansible-project] Issue with conditionals

2016-01-04 Thread Josh Smift
ER> when: (alias != "leia") or (alias != "luke") or (alias != "vader") ER> ER> If I turn those conditionals from != to ==, the play only runs on ER> those 3 servers as expected. But if I run it like it is above, it runs ER> on ALL hosts. No matter what your alias is, at least one of those condit

[ansible-project] how to get tag_name instead of private ip address?

2016-01-06 Thread Josh Smift
Try this, in ec2.ini: vpc_destination_variable = Name (Or something other than Name if you want to use a different tag.) -Josh (j...@care.com) This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILE

[ansible-project] Inheriting static group_var data with dynamic inventory?

2016-01-07 Thread Josh Smift
AQ (https://github.com/caredotcom/ansible-quartermaster) might be of interest. -Josh (j...@care.com) This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use,

[ansible-project] How to use a variable within a variable

2016-01-28 Thread Josh Smift
JL> 3) Now, I need to use the variable passed on command line to get the JL> variable from /vars/main.yml: JL> {{ redis_password.{{ app_env }} }} Yep, just the syntax is wrong. Two things: (1) The {{ and }} marks just say "start parsing Jinja", so you don't ever need to nest them. (2) The d

Re: [ansible-project] YUM module Install loop too clever

2016-02-01 Thread Josh Smift
If you know that you have one particular page that needs to go first, and you know what it is, you could just create a second task (to run first) to install that package, and then a second task to install all the rest, right? -Josh (j...@care.com) This

[ansible-project] Merging inventories?

2016-02-14 Thread Josh Smift
We wrote a way to merge static and dynamic inventories; you could also use it to have static inventories in multiple files, and merge them together. https://github.com/caredotcom/ansible-quartermaster -Josh (j...@care.com) This email is intended for the

Re: [ansible-project] Group variables conditional based on OS distribution release

2016-02-27 Thread Josh Smift
We do stuff with inventory variales and dicts, like become_method: 5.7: doas 5.8: doas 6.0: sudo ansible_become_method: become_method[ansible_distribution_release] You can't do the >= thing this way, you have to enumerate all the options. (Or you could have a default and only en

[ansible-project] Re: Dealing with inconsistencies after failed runs

2016-03-09 Thread Josh Smift
Would a - meta: flush_handlers task, immediately after the copy task (or whatever populates /etc/aliases, and does the notify), do what you want in this case? It still wouldn't help if the SSH connection dies immediately after the copy task, but there's not a whole lot you *can* do in that case

[ansible-project] YAML Syntax Error

2016-03-14 Thread Josh Smift
AT> Before I start banging my keyboard into the window, I wanted to ask AT> why this task produces a Syntax Error: AT> AT> - name "cat /etc/shinken/modules/webui.cfg | grep 'modules AT> auth-cfg-password'" AT> shell: runuser -l shinken -c "cat /etc/shinken/modules/webui.cfg | I think y

Re: [ansible-project] Ansible role execution order is not serial

2016-04-12 Thread Josh Smift
BC> you cannot have multiple roles: declarations per play, if you want to BC> make this work in that order you need a 2nd play: If you really needed to do it in one play for some reason, you could have a 'pause' (or whatever) role, with one pause (or wait_for) task.

Re: [ansible-project] yml indentation quirkness

2016-04-14 Thread Josh Smift
You may be able to have your text editor insert spaces when you hit the tab key, if that's what you want. Google turned up recommendations for vi and Emacs, or search for your editor of choice. -Josh (j...@care.com) (apologies for the automatic corporate dis

[ansible-project] How can I figure out which version of Ansible an ansible-modules-core merge request first appears in?

2016-05-03 Thread Josh Smift
KS> This pull request: KS> https://github.com/ansible/ansible-modules-core/pull/2673 supposedly KS> adds MySQL 5.7 support on mysql_user. The last note says it's been KS> merged into the 2.0 stable and the devel branch, but it's not clear to KS> me if it means it's in the 2.0 release or the upcomin

[ansible-project] EC2 dynamic inventory + windows hosts, any way to do a group_vars for that?

2016-05-11 Thread Josh Smift
We wanted a way to combine static and dynamic inventories with a single set of inventory variables, and wrote a script to do it; check out https://github.com/caredotcom/ansible-quartermaster and see if it's any help (either as-is, or as an example, or for humor value, or whatever).

Re: [ansible-project] with_items task and when: statement

2016-05-19 Thread Josh Smift
The other thing you could do is define an empty value in a role default, if you're in a role. (There doesn't seem to be a way to do that if you're not in a role, i.e. to define a playbook default that can be overridden by group or host variables, at least not that I see in the precedence list at ht

[ansible-project] Variable within Variable

2016-05-19 Thread Josh Smift
P> I've made a dictionary declaring "apple: 'JameslikesApples'" and on the P> next line: "banana: 'IwentToSanFrancisco'". I need to be able to P> reference "JameslikesApples" in a shell command and I just can't see a P> way around it. I've tried {{ {{ basket }} }} but Ansible doesn't accept P> the

[ansible-project] Group ec2 instances and local machines together

2016-05-20 Thread Josh Smift
We wrote a sort of meta-inventory script to do this kind of thing; https://github.com/caredotcom/ansible-quartermaster might be useful (as is, as an example, as a warning, etc :^). (Wanting AWS things things with tag_whatever_foo, and static things in group 'foo', to both end up in the same Ansibl

[ansible-project] How to check file system is mounted?

2016-05-23 Thread Josh Smift
RF> Currently I'm doing the following but it doesn't work: RF> RF> - name: check if mounted RF> command: mount | grep RF> register: result RF> RF> - debug: var={{ result.stdout }} RF> RF> I get the error: RF> failed... 'Consider using mount module rather than running mount'... RF> stderr: RF>

[ansible-project] What's correct Jinja2 operator to do "less than" on a string?

2016-05-24 Thread Josh Smift
Hmm, this trivial playbook works for me: - hosts: localhost tasks: - debug: msg="Yep!" when: server_num < '03' With '--extra-vars server_num=02', I get TASK: [debug msg="Yep!"] ** ok: [localhost] => { "msg": "Ye

[ansible-project] Re: ec2.results is not being defined

2016-05-24 Thread Josh Smift
ES> does anyone know or have a clue why ec2.results wouldn't be populated? Random shots in the dark: - Is 'ec2' as a variable name clashing with the module name in some way? What if you do 'register: foo' instead? - What *is* in 'foo', if you 'debug: var=foo' it? Is it everything you'd expec

Re: [ansible-project] Re: What's correct Jinja2 operator to do "less than" on a string?

2016-05-24 Thread Josh Smift
RF> I see. I agree that doing math on strings is somewhat questionable. Well, strings can be sorted, and compared in that way. I wouldn't bet on what adding 1 to a string would do, but comparisons seem legit. http://jinja.pocoo.org/docs/dev/templates/#comparisons is where I found the comparisons

[ansible-project] Re: ec2.results is not being defined

2016-05-25 Thread Josh Smift
ES> I did try ec2.instances but it is only add the first host not all ES> three. I did do a debug on ec2 and ec2.instances and it is showing all ES> 3 instances that I'm turning up. Any ideas on that. This is only ES> happening on the add_hosts module. I have a wait for ssh to come up ES> task and

[ansible-project] Fact caching

2016-05-27 Thread Josh Smift
We have a use case similar to one I've seen in a couple of places, where (let's say) a web server has a template that needs to contain information about (let's say) all the app servers that are in their Ansible facts. If you do 'ap -t web.yml', with a play to gather facts from everyone and a play t

[ansible-project] Fact caching

2016-06-01 Thread Josh Smift
How does fact caching work with JSON files and expiration time? The particular weird symptom I'm seeing is that the cache file for a host is getting written to as various plays run, but the contents of the cache are stale. If the mtime of the cache file is what determines expiration, it seems like

Re: [ansible-project] template substitution

2016-06-01 Thread Josh Smift
PG> Many thanks for this information. For future reference where is this PG> documented? https://groups.google.com/forum/#!topic/ansible-project/qHyIjyal_Ic is a thread where it came up before, which says you can use a per template header to override this, you can see an example in the templa

[ansible-project] Variable in a variable

2016-06-10 Thread Josh Smift
WN> In a Jijna2 template I need a following variable from hostvars. WN> WN> hostvars['{{project}}-example.com'].ansible_eth0.ipv4.address I'm pretty sure something like hostvars[project + '-example.com'].ansible_eth0.ipv4.address will work. You might need to bracket-ify the whole thing, like

[ansible-project] Re: Variables from another server

2016-06-21 Thread Josh Smift
AS> If I dump hostvars, I can see the information I want does exist, I AS> just can't convince Google to show me an example to follow. In general, you want something like hostvars['server1']['ansible_ssh_host'] for the ansible_ssh_host variable on the host 'server1'; or, if the target hostname

[ansible-project] Re: Variables from another server

2016-06-21 Thread Josh Smift
http://docs.ansible.com/ansible/playbooks_variables.html has some more docs about this too. -Josh (j...@care.com) (apologies for the automatic corporate disclaimer that follows) This email is intended for the person(s) to whom it is addressed and may con

Re: [ansible-project] config managing JBoss II: The XMLening

2016-06-23 Thread Josh Smift
BC> The template module does this by default (the diff if ansible is BC> called with --diff), add a notify handler for the restart and you have BC> all the steps. Right, but with JBoss, the destination file may have been changed since Ansible pushed it out (because JBoss likes to rewrite its XML f

[ansible-project] Timestamp without gathering facts

2016-07-21 Thread Josh Smift
I want to come up with a timestamp for the current time; it doesn't have to be perfectly accurate, this is just to uniquely name something, but if I run it twice in a row I want to be pretty sure that the second time will be later than the previous time. Something like this: - name: Do something w

[ansible-project] Quotes and Jinja

2016-08-09 Thread Josh Smift
We have a task like - name: install thing and dependencies yum: name={{ item }} state=present with_items: - thing-"{{ thing_version }}" - dep1 - dep2 - dep3 where thing_version is sometimes 1.0 (say), and sometimes something else. This worked fine in Ansible 1.9

[ansible-project] How can I use ansible and ec2.py to manage multiple aws accounts

2016-08-10 Thread Josh Smift
If the main thing you need is to get inventory from multiple accounts, you might find ansible-quartermaster to be useful. You could probably use the 'includes' feature to call ec2.py multiple times, with different config files to use different AWS keys to access your different accounts. https://git

  1   2   >