Re: [ansible-project] How to use --extra-vars option to pass host variables in ansible-playbook

2016-02-29 Thread Tom Bamford
On 29 Feb 2016, at 9:41 AM, Dinesh Sekar wrote: > > Yes. If I give the arguments as below, then it would be normal variables or > global variables. > > ansible-playbook -i hosts .yaml --extra-vars > '{"management_interface":{"int": "em0","ip": "192.168.56.3"}}' > > But I'm looking for a

[ansible-project] Bad Google results for Ansible docs

2016-01-03 Thread Tom Bamford
Hi all I had thought the Ansible docs site was down, but it looks like the URL structure has changed and previous URLs indexed by Google are not being redirected. For example, these results: https://www.google.co.za/search?q=ansible+ec2_tag

Re: [ansible-project] Setting ANSIBLE_HOST_KEY_CHECKING per host

2015-03-04 Thread Tom Bamford
You could perhaps achieve this with a crafted ssh_config. Especially if your hosts are named predictably. Consider if your production hosts have names in the form host5.prod.domain.net and other environments are different such as host3.stage.domain.net A corresponding ssh_config might be (note th

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

2015-02-28 Thread Tom Bamford
On 26 February 2015 at 17:21, shirou wrote: Hi, > > This E-mail is a little bit old but I am in the same situation. > > ignore_errors: test_err | bool > > doesn't work for me on ansible 1.8.4 > > Is there any work around? > > The last time I needed to have conditional ignore_errors, because

Re: [ansible-project] Ansible Roles in 1.8.4 - Still inferior to include files for complex playbooks?

2015-02-24 Thread Tom Bamford
ery time--not sure. Depends > on your app.) > > This way you lose the intermediary playbooks, and end up with a single > playbook to do all of your restart tasks. > > If app1 and app2 roles are really close together, maybe you could > parameterize them, too: > > - { role: genericApp/stop

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

2015-02-17 Thread Tom Bamford
On 17 February 2015 at 16:16, Josh Smift wrote: > 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 file

Re: [ansible-project] Boolean variable being capitalized in templates? Best practice to work around?

2015-02-10 Thread Tom Bamford
Hi Phil Don't know if there is an official short way to do this, but there is a 'to_json' filter which seems to work on simple booleans, which could be slightly preferable to 'lower'? Tom On 11 February 2015 at 00:24, Philip Lombardi wrote: > I have some variables defined in a role such as: >

Re: [ansible-project] Make ansible-playbook accept a roles-path argument?

2015-02-10 Thread Tom Bamford
Thanks James, I didn't know about this. Will come in very handy! On 10 February 2015 at 08:27, James Cammarata wrote: > Hi Daniel, you can use the environment variable > ANSIBLE_ROLES_PATH=/path/to/roles in front of ansible-playbook to modify > the path on the fly, without having to modify your

Re: [ansible-project] Write template from a string input

2015-02-10 Thread Tom Bamford
Hi Michael The copy module does have a content parameter that should do what you want. Regards Tom On 10 February 2015 at 13:21, Michael Stucki wrote: > Hi! > > I'm trying to write a file. As it's only one line, I would like to set it > from a string input, not from a template file. Just some

Re: [ansible-project] Parsing playbooks with full Jinja templating

2015-02-02 Thread Tom Bamford
Jinja templating doesn’t work in playbooks in that way. Lots of variable constructs are actually parsed with jinja2, so you can do stuff like - set_fact: myvar: "{% if something %}this{% else %}that{% endif %}" As Giovanni mentioned, there are numerous looping constructs for things like task

Re: [ansible-project] Parsing playbooks with full Jinja templating

2015-02-02 Thread Tom Bamford
Hi Anand Are you sure your indenting is correct? Here’s an example from one of my role task files, known working with Ansible v1.8.2 (packages trimmed for brevity) --- - name: Install packages (apt) apt: pkg: - bash-completion - bind9utils - vim-nox - zsh state:

Re: [ansible-project] Parsing playbooks with full Jinja templating

2015-02-01 Thread Tom Bamford
Hi Anand You actually can (and I prefer to) write your playbooks with that kind of plain YAML syntax. e.g. - hosts: localhost tasks: - name: blah yum: name: - mypackage - otherpackage state: present - name: blurh copy: src: myfile

Re: [ansible-project] Re: Pass variable to hosts: in playbook

2015-01-22 Thread Tom Bamford
Agreed with James, dynamically adding hosts to groups is the way to go. I believe that the hosts: lines are evaluated before the playbook is run, so the only variables you can use there are ones set with -e vmname=something On 20 January 2015 at 18:04, James Martin wrote: See my original respons

Re: [ansible-project] Re: How does Ansible know what account to use for the SSH connection and sudo

2015-01-22 Thread Tom Bamford
Note that if you are using ssh transport (not sure about Paramiko), and you have a matching host in ssh_config with a User line, that will be used. So given that ~you/.ssh/config contains Host myhost User root and you invoke the following as you… ansible myhost -a whoami …Ansible will connect

Re: [ansible-project] Append shell results on multiple servers to local file

2015-01-17 Thread Tom Bamford
each server. I really wanted to run the > playbook in one shot against all servers. I could have just created a for > loop using ssh to do it, but I really wanted to see if I could get it to > work with Ansible. > > Jim McMahon > On Jan 17, 2015, at 11:36 PM, Tom Bamford wrote: &

Re: [ansible-project] Running from source forces new terminals to cd into ansible's source dir

2015-01-17 Thread Tom Bamford
Hi David I’m also using zsh although usually only source env-setup when I need it. If I do source it from ~/.zshrc, it doesn’t change my working directory. Does adding set -x to the beginning of, and set +x to the end of the env-setup file offer any clues? ​ On 16 January 2015 at 19:28, David Re

Re: [ansible-project] Append shell results on multiple servers to local file

2015-01-17 Thread Tom Bamford
Could you perhaps save the results into different files on the local machine (such as /tmp/local_action.{{ inventory_hostname }}), then assemble them into a single file as a subsequent task? There is an assemble module that may do the job. ​ On 18 Jan

Re: [ansible-project] Gathering facts about servers newly created using the rax modules and dynamic inventory

2015-01-16 Thread Tom Bamford
Hi Dan I see when you are invoking the add_host module from line 132 onwards in roles/infrastructure/tasks/main.yml, you add them to differently named groups than you otherwise reference from dynamic inventory. What happens if you add them to the same group names with add_host? Regards Tom On 1

Re: [ansible-project] "vars:" before "- hosts:"

2015-01-16 Thread Tom Bamford
Sorry I misread your second question. To answer it properly, I’m fairly certain that you will get the same behaviour with the shell module as you would running a script from an interactive shell, so sourcing scripts and exporting from a sourced script will work just fine. With the correct playbook

Re: [ansible-project] Can we put /etc/ansible/hosts file in other place?

2015-01-16 Thread Tom Bamford
You can place your inventory file(s) anywhere you like. Reference them from ansible.cfg , or using -i /path/to/inventory ​ On 16 January 2015 at 03:32, zixu mo wrote: > Can we put /etc/ansible/hosts file in other place? > > such as /home

Re: [ansible-project] "vars:" before "- hosts:"

2015-01-16 Thread Tom Bamford
I’m not sure exactly what you are asking with regards to the playbook syntax, but it is not valid. To my knowledge, Ansible will not carry exported variables from one shell script to the next, unless you somehow capture them with some conbination of register: and set_fact On 16 January 2015 at 1

Re: [ansible-project] no_log: True being ignored

2015-01-15 Thread Tom Bamford
/ansible-tmp-1421353307.86-275694889373920/command 2015-01-15 22:21:47,873 p=1876 u=tom | EXEC ['/bin/sh', '-c', u'LANG=C LC_CTYPE=C /usr/bin/python /Users/tom/.ansible/tmp/ansible-tmp-1421353307.86-275694889373920/command; rm -rf /Users/tom/.ansible/tmp/ansible-tmp-142135

Re: [ansible-project] using Ansible-Vault vars to run local bash scripts

2015-01-15 Thread Tom Bamford
I am using 1.8.2 which appears to be exposing the entire command, args and all, when no_log is set to true. See https://groups.google.com/d/msg/ansible-project/ypVNNST6Gb8/n7ER3RY200AJ This is probably a regression? Regards Tom On 15 January 2015 at 22:09, Brian Coca wrote: > Tom, environment

Re: [ansible-project] using Ansible-Vault vars to run local bash scripts

2015-01-15 Thread Tom Bamford
ith the security concerns. It would be simpler to just hardcode the values > on the script this way. > > The approach I'm looking is to use the ansible-vault variables on the fly > with the script and after the execution step to not leave any traces. > > Thanks again, > N

Re: [ansible-project] using Ansible-Vault vars to run local bash scripts

2015-01-15 Thread Tom Bamford
project/CAJ5XC8nFdJhruOzfaf%2BoFteqTAhquTG87Co-q74G6rf241hs2Q%40mail.gmail.com > . > For more options, visit https://groups.google.com/d/optout. > -- Tom Bamford *@Planet* ATPLANET (Pty) Ltd atpla.net Cell: +27 (0)79-095-7112 Fax: +27 (0)86-599-1310 -- You received this message becaus

Re: [ansible-project] Re: Collecting a list of internal IPs from EC2

2015-01-15 Thread Tom Bamford
Hi Tzach I usually approach instance termination by matching the instances with ec2 dynamic inventory, then add them to a group and terminate them in another play targeted at the newly created group, based on their instance id (which is automatically added as an inventory variable by the ec2 inven

Re: [ansible-project] using Ansible-Vault vars to run local bash scripts

2015-01-15 Thread Tom Bamford
Hi Nicolas Just a couple of suggestions that spring to mind: You could pass in the vars as environment variables, although these do unfortunately get exposed in syslog and console output. Alternatively you could maybe write them to files on the target host (be it localhost or another host) with

Re: [ansible-project] no_log: True being ignored

2015-01-14 Thread Tom Bamford
Thanks, I think the docs could perhaps be clarified a little in this regard. From http://docs.ansible.com/faq.html#how-do-i-keep-secret-data-in-my-playbook - “if you have a task that you don’t want to show the results or command given to it when using -v (verbose) mode, the following task or playbo

Re: [ansible-project] Feature: User-defined modules as yaml task lists?

2015-01-14 Thread Tom Bamford
n separate task files, or separate roles depending on the complexity. I don't believe in this case that some duplication is a bad thing. Hope this helps. Tom On 14 January 2015 at 13:37, wrote: > On Tue, 13 Jan 2015, Tom Bamford wrote: > > > If you want greater control of

Re: [ansible-project] Having issues using a variable in a playbook

2015-01-13 Thread Tom Bamford
Hi Benjamin Look at specifying variables using group_vars or host_vars (see http://docs.ansible.com/intro_inventory.html#splitting-out-host-and-group-specific-data ) There is a special group 'all' of which all hosts are automatically a member. Regards Tom On 14 January 2015 at 02:15, Benjamin

[ansible-project] no_log: True being ignored

2015-01-13 Thread Tom Bamford
Hi Running Ansible 1.8.2 and I am trying to prevent sensitive information for a task from reaching the log at ANSIBLE_LOG_PATH or the console where ansible-playbook is running. My task: - name: Dump database command: pg_dump -with -some -params environment: PGPASSWORD: mysecret no_log:

Re: [ansible-project] role dependencies and variables

2015-01-13 Thread Tom Bamford
Add the following to roles/php-fpm/meta/main.yml and that role will be invoked for each dependency allow_duplicates: yes ​ On 13 January 2015 at 20:54, vadimv Vatlin wrote: > Hello > > I want to create meta role to setup web site configuration nginx + php-fpm > > > playbook client.yml: > > - r

Re: [ansible-project] Feature: User-defined modules as yaml task lists?

2015-01-13 Thread Tom Bamford
If you want greater control of when your common tasks get executed, I would be more inclined to use rules and have verbose playbooks with the execution order explicitly specified. Perhaps if you could give a better idea of what your common tasks are and the context in which you want to run them?

Re: [ansible-project] Conditionals in sudo

2015-01-13 Thread Tom Bamford
Hi Raja I struggled with this, and the approach I settled with is to duplicate the task, having one with the 'sudo:' parameter and one without, and each having a 'when:' conditional. - command: something sudo: yes when: env == 'development' - command: something when: env != 'development'

Re: [ansible-project] Variables in "when" statement

2015-01-13 Thread Tom Bamford
Hi Wojtek The error you are getting is due to inconsistent quoting. You may also need to cast your variable. Try one of these: - include: some_playbook.yml when: "{{ some_variable | bool }} == True" or shorter: - include: some_playbook.yml when: "{{ some_variable | bool }}" See http://docs

Re: [ansible-project] Force ansible to use IPv4 / IPv6?

2015-01-12 Thread Tom Bamford
39ce-0f31-4d36-9a29-58f8bf37d5ca%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Tom Bamford *@Planet* ATPLANET (Pty) Ltd atpla.net Cell: +27 (0)79-095-7112 Fax: +27 (0)86-599-1310 -- You received this

Re: [ansible-project] Problems running mysql_user

2015-01-11 Thread Tom Bamford
Hi Dirk Would you not need to grant SELECT instead of USAGE? According to MySQL docs, USAGE is granted at the server level. When I create a user locally (with or without Ansible), that user gets USAGE on *.* but it doesn't allow them to see any databases. Regards Tom On 11 January 2015 at 07:2

Re: [ansible-project] ansible-playbook: How to gather facts from machine Y although you run with --limit="X"

2015-01-11 Thread Tom Bamford
Hi Eric There is a feature called Fact Caching which can facilitate this: http://docs.ansible.com/playbooks_variables.html#fact-caching Regards Tom On 10 January 2015 at 17:06, Eric Feliksik wrote: > I have an ansible role for machine X that uses use {{ > hostvars['Y']['network_address'] }} i

Re: [ansible-project] Referencing Ansible Variables

2015-01-08 Thread Tom Bamford
Hi Peter As Fred says, the variables are not in scope for both plays. You will need to declare your variables such that both plays can see them. You could put them into a separate file and reference it with vars_files in both plays, or you could pass them in as extra vars on the command line. You

Re: [ansible-project] handler is called in v1.8.2

2015-01-08 Thread Tom Bamford
Can you post some output? A handler will only be called if the task was considered changed. On 8 January 2015 at 05:56, hce h wrote: > Hi, > > I have a task to use notify statement to call the handler, but it did not > seem called. The output of tasks did not show the handler task. Should the >

Re: [ansible-project] PDF Documentation

2015-01-07 Thread Tom Bamford
>> Matt Martz >> @sivel >> sivel.net >> > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to ansible-project+unsubscr..

Re: [ansible-project] Filter hosts based on facts

2015-01-07 Thread Tom Bamford
Of course, this approach applies to playbooks. I'm not sure how to (best) accomplish this with the standalone ansible command. Regards Tom On 7 January 2015 at 13:53, Tom Bamford wrote: > Hi Vasek > > You can declare dynamic groups based on arbitrary facts, and then apply >

Re: [ansible-project] Filter hosts based on facts

2015-01-07 Thread Tom Bamford
Hi Vasek You can declare dynamic groups based on arbitrary facts, and then apply tasks or roles to those groups. There is an example at http://docs.ansible.com/playbooks_best_practices.html#operating-system-and-distribution-variance which seems to do exactly what you want. Regards Tom On 7 Janu

Re: [ansible-project] stopping daemons before apt-get remove?

2015-01-06 Thread Tom Bamford
You could first check if the package is installed and register a variable to that effect. - shell: dpkg -l foo changed_when: False failed_when: False register: foo_installed - service: name=foo enabled=no state=stopped when: foo_installed.rc == 0 ​ On 21 December 2014 at 01:38, Kevin Bu

Re: [ansible-project] Calculating with Variables?

2015-01-05 Thread Tom Bamford
Hi Ulrich How about a ‘for’ loop (in Jinja2) contained as a parameter to the set_fact module, iterating the facts you gathered as presented in the {{ hostvars }} magic variable? Regards Tom On 4 January 2015 at 03:02, Ulrich Hochholdinger < ulrich.hochholdin...@gmail.com> wrote: Hi, > I just st

Re: [ansible-project] Pass dictionary variables to the role does not work

2015-01-04 Thread Tom Bamford
What version of Ansible are you using? It works for me with v1.8.2. Even when referencing an undefined variable, I don't get an exception. Can you paste the nfs-client task which fails? Tom On 5 January 2015 at 05:55, hce h wrote: > Hi, > > I cannot install ansible to one of our NFS server, I

Re: [ansible-project] Re: Wildcard in group of hosts

2015-01-04 Thread Tom Bamford
The default inventory has its limitations, but that's exactly why Ansible supports dynamic inventory plugins, which are straightforward to write. That said, you can use a form of patterns in static inventory, though I don't know if it expands beyond simple numeric and character ranges. On 4 Janu

Re: [ansible-project] include: "{{ ansible_os_family }}.yml" not working

2015-01-04 Thread Tom Bamford
anuary 2015 at 22:28, Francisco Reyes wrote: > > On Sunday, January 4, 2015 2:08:15 PM UTC-5, Tom Bamford wrote: >> >> The {{ ansible_os_family }} fact is usually set to the parent (or other >> ancestor) distribution. For Ubuntu it will be set to “Debian”. You might >>

Re: [ansible-project] include: "{{ ansible_os_family }}.yml" not working

2015-01-04 Thread Tom Bamford
Hi Francisco The {{ ansible_os_family }} fact is usually set to the parent (or other ancestor) distribution. For Ubuntu it will be set to “Debian”. You might want to use {{ ansible_distribution }} instead (or rename your included file to Debian.yml - given that there is typically little to no diff

Re: [ansible-project] Check file for staleness or comparing ctime to current time in Ansible

2015-01-04 Thread Tom Bamford
Hi Mirko Ansible provides the current time in various formats as facts. ansible_date_time.epoch could be what you need? Regards Tom On 3 January 2015 at 23:19, Mirko Friedenhagen wrote: Hello, > > I want to use Ansible for updating Jenkins plugins. So I download the > update information via cu

Re: [ansible-project] Escaping special characters inside variable?

2015-01-03 Thread Tom Bamford
Hi John Python has the re.escape() method but I don't know if Ansible exposes this in the form of a Jinja2 filter (seemingly not, looking at https://github.com/ansible/ansible/blob/devel/lib/ansible/runner/filter_plugins/core.py ). I'm curious, why both the check with grep *and* the regexp option

Re: [ansible-project] Use host var in a task in when clause

2015-01-02 Thread Tom Bamford
Hi Michael Ansible considers “yes” strings as True booleans but for comparison you can use the bool filter. Perhaps try something like this: - debug: msg="run this task" when: elasticsearch_purge_old_indices_node|bool On 3 January 2015 at 00:09, Michael Liu wrote: Hey All, > > I'm trying to

Re: [ansible-project] Help me understand 'when:' conditionals. Cause I seem to fumble with them quite frequently.

2014-12-30 Thread Tom Bamford
Hi For substring comparisons, I use the ‘in’ keyword like this: - name: Get timezone info shell: date register: zoneinfo changed_when: no - name: If timezone is not CST then remove /etc/localtime and call set timezone handler file: path=/etc/localtime state=absent when: '"CST" in zonein

Re: [ansible-project] Overriding log_path for each invocation of ansible-playbook

2014-12-29 Thread Tom Bamford
Hi Brian Thank you! This will work nicely. Regards Tom On 29 December 2014 at 18:21, Brian Coca wrote: > Configuration is not exposed as variables, so setting a variable named > log_path will not affect the configuration setting. Only one file is > read on a 'first found' basis, they are not

Re: [ansible-project] Set boolean to true based on a fact

2014-12-29 Thread Tom Bamford
Hi Willem Instead of declaring them as vars in your play, try the set_fact module instead. Regards Tom On 28 December 2014 at 15:20, Willem Bos wrote: > Hi All, > > I would like to be able to set a boolean to true only when two facts have > certain values: > > --- > - hosts: all > > vars: >

[ansible-project] Overriding log_path for each invocation of ansible-playbook

2014-12-27 Thread Tom Bamford
way to get Ansible to parse all config files and give corresponding precedence to individual settings therein? Regards Tom ​ -- Tom Bamford *@Planet* ATPLANET (Pty) Ltd atpla.net Cell: +27 (0)79-095-7112 Fax: +27 (0)86-599-1310 -- You received this message because you are subscribed to the Goo

[ansible-project] Re: Variable scope issue: value from a different role being used

2014-09-29 Thread Tom Bamford
Oh, the role name mismatch between what is in deploy.yml and the following filenames (deploy-projectA vs projectA) really is just a typo (doh). Tom On 29 September 2014 17:13, Tom Bamford wrote: > Hi all > > I'm running from HEAD (recently ran 'git pull --rebase &&

[ansible-project] Re: Variable scope issue: value from a different role being used

2014-09-29 Thread Tom Bamford
/09/29 14:22:52 (GMT +000) configured module search path = /usr/share/ansible On 29 September 2014 17:16, Tom Bamford wrote: > Oh, the role name mismatch between what is in deploy.yml and the following > filenames (deploy-projectA vs projectA) really is just a typo (doh). > > T

[ansible-project] Variable scope issue: value from a different role being used

2014-09-29 Thread Tom Bamford
as behaving as expected* when running from an [unknown] earlier commit of ansible so I think it was introduced recently. * Expected behaviour would be to use the variables from projectB/vars/main.yml I have ensured that manually performing a git clone and git checkout does really work with the correct de

Re: [ansible-project] Roles with multiple OS versions

2014-08-25 Thread Tom Bamford
; and ansible_distribution_version|int == 7 The 'int' filter may not actually be required. It might look inelegant but it's very clear to read. The only issue for me is that ansible-playbook displays a skipped status for each task it doesn't run for a host instead of just ignor

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

2014-08-25 Thread Tom Bamford
file: path={{ home_dir }}/.ssh state=directory mode=0700 owner={{ file_owner }} group={{ file_owner }} No ">" is needed if you indent like this. I like to hard wrap at 80 chars for easier diff reading but one line per param is a bit overkill for my taste. -- Tom Bamford *@Planet*

Re: [ansible-project] Choosing from conflicting values in multiple roles

2014-08-14 Thread Tom Bamford
this shared global setting, have you considered configuring these values per virtualhost? Regards -- Tom Bamford *@Planet* ATPLANET (Pty) Ltd atplanet.co.za Cell: +27 (0)79-095-7112 Fax: +27 (0)86-599-1310 -- You received this message because you are subscribed to the Google Groups "Ans

Re: [ansible-project] Issue using apt with prefix

2014-03-31 Thread Tom Bamford
If you really don't want to expand all your package names, something like this may work for you: - name: set apache module package prefix set_fact: apache_mod_prefix=libapache2-mod- - name: install additional modules apt: pkg="{{ apache_mod_prefix }}{{ modules|join(',' + apache_mod_prefix) }