[ansible-project] Quick way for testing new Ansible roles

2018-05-21 Thread Behrang
quick way to test newly created roles? Cheers, Behrang -- 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...@googlegro

[ansible-project] Re: Quick way for testing new Ansible roles

2018-05-23 Thread Behrang
Thanks Mischa. I ended up doing something similar with Vagrant. - Created a symlink from the tests/roles dir to the root dir of the role I am writing - Installed the *vagrant-hostupdater* to add a custom host name to the Vagrant box I use for testing - Updated the inventory and

[ansible-project] Re: Quick way for testing new Ansible roles

2018-05-22 Thread Behrang
. On Tuesday, May 22, 2018 at 1:22:28 PM UTC+10, BIJAY PARIDA wrote: > > Host example is not a valid host name. > > - hosts: localhost > > On Tuesday, 22 May 2018 07:31:24 UTC+5:30, Behrang wrote: >> >> Hi, >> >> In the docs <https://galaxy.ansible.com/intro#r

[ansible-project] Multiple plays in the same playbook resolve group variables incorrectly

2018-05-27 Thread Behrang
hines/default/virtualbox/private_key -vv 12:45:01 ansible-playbook 2.5.3 config file = /Users/behrang/ansible/ansible.cfg configured module search path = [u'/Users/behrang/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /us

[ansible-project] Re: Multiple plays in the same playbook resolve group variables incorrectly

2018-05-27 Thread Behrang
ommunity/check-procs.rb -c 1 -p java.*payroll" roles: - sensu-check-role On Monday, May 28, 2018 at 12:55:09 PM UTC+10, Behrang wrote: > > Source code: https://github.com/behrangsa/sample-ansible-role > > Background: > > I have three different environments: test, s

[ansible-project] How to keep the content returned by uri from being printed in the console?

2014-07-09 Thread Behrang Saeedzadeh
Hi all, Is there a way to stop Ansible from printing the content returned from a uri in the console and have return_content=true? Thanks in advance, Behrang -- You received this message because you are subscribed to the Google Groups Ansible Project group. To unsubscribe from this group

[ansible-project] Including timestamps in PLAY [host] *** messages

2014-08-19 Thread Behrang Saeedzadeh
] Thanks in advance, Behrang -- 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...@googlegroups.com. To post to this group, send email

[ansible-project] Support looking up binary files as HTTP-based APIs are increasingly supporting uploading of BASE64 encoded binaries in JSON documents.

2017-09-19 Thread Behrang Saeedzadeh
"SOURCE"} The lookup command cannot load binary files though. Consequently, we need to use `command` and `curl` in our Ansible playbooks. Any plans to allow embedding BASE64-encoded binaries in JSON payloads when using the `uri` module? Thanks in advance, Behrang -- You received this

Re: [ansible-project] Is there a way to provide default values to a set of tasks?

2017-10-02 Thread Behrang Saeedzadeh
s to those roles > - more info here: > http://docs.ansible.com/ansible/latest/playbooks_reuse_roles.html#using-roles > > kind regards > Pshem > > > On Mon, 2 Oct 2017 at 15:49 Behrang Saeedzadeh <behr...@gmail.com > > wrote: > >> Hi, >&

[ansible-project] Is there a way to provide default values to a set of tasks?

2017-10-01 Thread Behrang Saeedzadeh
Hi, I am writing a role that contains a dozen of tasks that invoke REST APIs. All tasks have a set of common and identical configurations: - name: Task 1 uri: validate_certs: False method: POST user: "{{ user }}" password: "{{ pass }}" force_basic_auth: yes

[ansible-project] Is there a way to run tasks that have ALL of the tasks given as parameters to ansible-playbook?

2017-10-11 Thread Behrang Saeedzadeh
For example, let's pretend we have these tasks: - name: Task 1 tags: - foo - bar - name: Task 2 tags: - foo - name: Task 3 tags: - bar Is there a way to only execute tasks that have both of *foo* and bar *tags*? That's, only execute* Task 1*? -- You received this

[ansible-project] Re: Is there a way to run tasks that have ALL of the tasks given as parameters to ansible-playbook?

2017-10-11 Thread Behrang Saeedzadeh
ever, as far as I know, there is > no AND type of operator for tags. > > On Thursday, October 12, 2017 at 12:04:20 PM UTC+11, Behrang Saeedzadeh > wrote: >> >> For example, let's pretend we have these tasks: >> >> - name: Task 1 >> tags: >> - fo

[ansible-project] Does Ansible support inclusion of no-op/empty/placeholder tasks?

2017-10-12 Thread Behrang Saeedzadeh
In some test frameworks, we can start a test suite by providing a list of empty tests. Then we can implement the tests one by one. Similarly, I want to start a playbook by only providing the set of tasks I want to execute, without implementing them: - hosts: localhost tasks: - name: Step

[ansible-project] Is there a cleaner way to use json_query to filter an array based on the value of an attribute?

2017-10-17 Thread Behrang Saeedzadeh
Hi, The version of Ansible we are using does not support selectattr to filter a list based on attribute names. So I instead use something like this: set_fact: thing: '{{ (things | json_query("[?thing_name==''" + a_thing_name + "'']") | list)[0] }}' Is there a cleaner way to do this?

Re: [ansible-project] Looking for a more elegant way to declare complex variables

2017-11-20 Thread Behrang Saeedzadeh
Oops. I didn't know this module existed. I am maintaining a set of scripts that was written before 2.0 and this module were released. On Tuesday, November 21, 2017 at 1:45:25 AM UTC+11, Shanker Balan wrote: > > Hi Behrang, > > Comments inline... > > > On 20-Nov-2017,

Re: [ansible-project] Looking for a more elegant way to declare complex variables

2017-11-20 Thread Behrang Saeedzadeh
I want to pretty print the generated JSON file. Otherwise I would have used the template module. On Tuesday, November 21, 2017 at 1:51:30 AM UTC+11, Brian Coca wrote: > > Just a note, this task does x2 transformations it does not need to, if > you use template directly you avoid many problems.

[ansible-project] Looking for a more elegant way to declare complex variables

2017-11-19 Thread Behrang Saeedzadeh
Sensu is monitoring services like Nagios and the things it should monitor can be configured with JSON check definition files . A JSON check definition file can have one or more check definitions. Here is a simplified

[ansible-project] Why sometimes result of tasks looping over with_items entries are printed in one line and sometimes in multiple lines

2017-11-19 Thread Behrang Saeedzadeh
For example: TASK [hal9000 : Install packages] ok: [localhost] => (item=[u'python-lxml', u'jdk1.8.0_92']) TASK [hal9000 : Copy configurations] * ok: [localhost] => (item=a) ok: [localhost] => (item=b) ok: [localhost] => (item=c) ok: [localhost] => (item=d)

Re: [ansible-project] Is there a cleaner alternative to '{{ (things | json_query("[?name==''" + thing_name + "'']") }}'

2017-10-30 Thread Behrang Saeedzadeh
gt; set_fact: > enabled_ports: "{{ intfs | json_query(enabled)}}" > vars: > enabled: "values(@)[?is_enabled && is_up && vlan_tag == `{{ > mgmt_vlan }}`]" > > kind regards > Pshem > > > On Mon, 30 Oct 201

[ansible-project] Is there a cleaner alternative to '{{ (things | json_query("[?name==''" + thing_name + "'']") }}'

2017-10-29 Thread Behrang Saeedzadeh
Is there a cleaner alternative to: '{{ (things | json_query("[?name==''" + thing_name + "'']") }}' In particular, ideally I want to avoid: - String concatenation - Escaping of quotes -- You received this message because you are subscribed to the Google Groups "Ansible Project"

[ansible-project] Refactoring variables to avoid hard coding the same value over and over again

2017-10-19 Thread Behrang Saeedzadeh
I want to refactor the following vars file/playbook pair, to avoid hard-coding the app name in the value for log_dir attributes. --- # some-role-vars.yml some_role_config: - name: app1 log_dir: "/var/log/app1/app1.log" - name: app2 log_dir: "/var/log/app2/app2.log" - name: