[ansible-project] Re: exporting grafana dashboards (containerised) using ansible

2020-01-29 Thread Dylan Martin
That's a pretty vague question.  Could you tell us what you've done and 
where you are stuck?

On Monday, January 27, 2020 at 7:56:59 AM UTC-8, Vishal Bobade wrote:
>
> Hello,
>
> I am looking forward to export grafana json dashboards using ansible. 
> Could you please help me on how can I use dockerized grafana to do so .
>
> Regards,
> vbob
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f68eca4c-4d30-472e-b0a4-ea192482aada%40googlegroups.com.


[ansible-project] Re: Ansible WinRM dont run concurrent process

2020-01-29 Thread Dylan Martin
How are you making them concurrent?  IE what does your play look like?  

If you have three conventional separate ansible tasks, that won't work.  
You'd need a single task that launches all 3 or use async.

https://docs.ansible.com/ansible/latest/user_guide/playbooks_async.html

If you're already using async, show us your playbook.

On Wednesday, January 29, 2020 at 3:31:51 AM UTC-8, wagfeliz wrote:
>
> Hi,
>
> We have 3 playbooks that runs concurrently winrm process on a windows 
> server, I did notice even when I start all of then in the same time, only 1 
> runs, the others get stuck and wait for the first to finish, then starts.
>
> I did follow all the documentation that I could find and this is my 
> current conf :
>
> PS C:\Windows\system32> winrm get winrm/config/Winrs
> Winrs
> AllowRemoteShellAccess = true
> IdleTimeout = 720
> MaxConcurrentUsers = 10
> MaxShellRunTime = 2147483647
> MaxProcessesPerShell = 25
> MaxMemoryPerShellMB = 1024
> MaxShellsPerUser = 30
>
> All the 3 process runs 3 tasks each on winrm.
>
> Is this an normal behavior ? What can I do to change that ? Should it be 
> able to run in parallel ?
>
> There is any docs someone can point me out about how to setup winrm to 
> allow +2 process to run simultaneously ?
>
>
> Best Regards,
> Wagner.
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c3adce88-2364-4c07-b39f-860a8bb1356d%40googlegroups.com.


[ansible-project] Re: Quick question- how to run ansible playbook on Saturday night at 12 PM and save the output in amazon s3 bucket

2020-01-29 Thread Dylan Martin
What environment are you in?

I have linux servers in a datacenter.  I'd write a shell script to run the 
play, output to a file and copy the file to s3.  Then I'd use cron to 
schedule the job.  Of course, you'd need to use a passwordless ssh key or 
set up ssh-agent ahead of time to work with cron, which can be a little 
tricky.

So, basically how you'd schedule any task, with extra attention paid to the 
ssh auth.

On Monday, January 27, 2020 at 11:08:26 PM UTC-8, Work-Hard wrote:
>
> Quick question- how to run ansible-playbook on Saturday night at 12 PM and 
> save the output in the amazon s3 bucket- "abc"?
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c587ac7f-2cf8-45bf-a80e-15e29efefff3%40googlegroups.com.


[ansible-project] waits for password when I don't want it to

2020-01-29 Thread Dylan Martin
Hi all.

I have an environment with several hundred unreliable machines.  Sometimes 
they're just dead, sometimes they're misconfigured.   I always encounter 
some where the keys in my ssh-agent don't work and it prompts me to enter 
the password and it waits for me to hit enter a bunch of times before the 
play will proceed.  

Is there a way to configure ssh or ansible to just fail when this happens?  
I sometimes will run plays with password auth instead of ssh keys, so I 
don't want to completely disable that.

Thanks!
-Dylan

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6e4e38d9-2f2b-42cb-b072-01d838f68449%40googlegroups.com.


[ansible-project] win_timezone change does not survive reboot

2019-11-27 Thread Dylan Martin
My timezone was Pacific Standard Time.  I used the win_timezone module to 
set it to UTC.  I appeared to work.  The TZ was UTC.  After reboot, the TZ 
was Pacific Standard Time again.

Is this expected?  Is there a way to make TZ change persist after reboot?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/596c04f7-f5d6-44ee-8dd5-30e3a9e0eefb%40googlegroups.com.


[ansible-project] Weird Windows Path Problem

2019-06-23 Thread Dylan Martin
Hi, I'm using Ansible 2.8 on Ubuntu and I'm trying to make a directory to a 
windows box.  

But wait!  I hear you say, what about 
https://docs.ansible.com/ansible/latest/user_guide/windows_usage.html#path-formatting-for-windows
 
?
Read it.  

If I use an unquoted or single quoted string, like so:

 - win_file:
   path: C:\foo

I get 

"path C:\\foo will not be created"

If I use a double quoted string, like so:

  - win_file:
path: "C:\foo"

I get 

"Get-AnsibleParam: Parameter 'path' has an invalid path 'C:\foo' specified."

Help!

-- 
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 to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5dc3be92-fd48-48f6-8cd6-f4188816d3f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Raw module invoking /usr/bin/python

2018-09-24 Thread Dylan Martin
I assume I broke a config somewhere because this makes no sense:

$ ansible -vvv '*' -i hosts.isp-east-stage -M raw -a 'whoami' -u ubuntu -l 
X.X.X.X

ansible 2.5.1
  config file = /home/dmartin/.ansible.cfg
  configured module search path = 
[u'/home/dmartin/.ansible/plugins/modules', 
u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0]
Using /home/dmartin/.ansible.cfg as config file
Parsed /home/dmartin/kafka-norancher/hosts.isp-east-stage inventory source 
with ini plugin
META: ran handlers
Using module file 
/usr/lib/python2.7/dist-packages/ansible/modules/commands/command.py
 ESTABLISH SSH CONNECTION FOR USER: ubuntu
 SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 
StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey 
-o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 -o 
ControlPath=/home/dmartin/.ansible/cp/5a5de34988 X.X.X.X '/bin/sh -c 
'"'"'/usr/bin/python && sleep 0'"'"''
 (127, '', '/bin/sh: 1: /usr/bin/python: not found\n')
X.X.X.X | FAILED! => {
"changed": false,
"module_stderr": "/bin/sh: 1: /usr/bin/python: not found\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 127
}

Any idea what's going on?

Oh, I'm trying to install python on some ubuntu instances in AWS.

Thanks!

-Dylan

-- 
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 to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d4a47176-cc3a-4c1d-b8b5-164f9d24e73f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Check if disk is in use before partitioning?

2018-08-10 Thread Dylan Martin
I all.  

I've used parted and lvm (lvg & lvol) to set up machines, but I recently 
broke a system when I repartitioned a disk that was already in use. 
(Wooops!)

Does anyone have a good idea how to determine if a block device is already 
in use?  By "in use" I mean, mounted in some way.

Thanks!
-Dylan 

-- 
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 to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/30e12558-0ad3-4420-9749-035ce905d720%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Management of multiple exclusive authorized_keys entries, for multiple users

2015-12-11 Thread Dylan Martin
Right of the top of my head, put user specific stuff in a dict in  vars 
file (or conditional include a file for each user), so you have a dict 
that's populated differently based on the value of a "user" var.

Then in a dependencies section in a meta/main.yaml, you just do
{ role: sshrolename, user: username }
{ role: sshrolename. user: otherusername }

Of course that's gonna be slow, so you could write your role to want a list 
of users, and then pass a list in the meta/main.yaml file.  You can always 
pass a list with one item.

On Friday, December 11, 2015 at 7:11:27 AM UTC-8, cmacrae wrote:
>
> Hi everyone.
>
> I've been mulling something over in my head, I've got something I want to 
> tackle, but I'm not sure how to go about doing so.
>
> Here's the scenario: I want to put together a tiny role that manages 
> user's authorized keys. Keys defined in the inventory 
> (host_vars/group_vars/playbook vars, etc.) should be the only ones present 
> in the user's authorized_keys file.
>
> I have some keys specified like so:
>
> root_ssh_public_keys:
>   member1:
> pubkey: ssh-rsa 
> B3NzaC1yc2EBIwAAAQEAvVO3ULx8fNGgInHCFQV6w/gEARBWyS9eA1qRaTEu4njawEjiqSGFHgPuvmgtKlft2MqbnCG3cokFKRAEOZEzy+jUMES8IQEHuSsJuZFnlUC4yzm1mI1OjJk9PwTLDD6OGJDL1gIkz37CYITbsaufS6gFrpoMBZhkVcVKk0JBnmwF/QZUD1uHKFLMtyVwvw8pzWcBcAYBBw5O6hjo2pRIX100bCdMxDrXwFp4yFiJPG6LCya4701whZpqgwk3d/RakJdZLA3pgAlVPZswz8ezj2U5PIYJl+LrUaPE57ZR/eVwNnBE7QPsKCCurIy1bLR0KXiqOmUzdzWDphYCelRurQ==
>  member1
>   member2:
> pubkey: ssh-rsa 
> B3NzaC1yc2EBIwAAAQEAtkScC/o1aDxaXFJdyTMhlF4UewNO/tdQf6EIYJzikSBNKECBjmvrM6bNaIkWA/AzB2dgTS0mug2aVomsBeyN8gAGfV/Wi3bO1kXuI23BmkPUn36OgE5ppQ0O2Gp8VjJaffV9EiYeEY/QlwnshAS9gfDPeTO+u5f0ZP0TZw29m+F3CKIJWPruDJJvXMkyc5qokh5kUpm0qYlhGyDi596st3Gsh/9LF/I2sEJH3LTP0gs0bWjbHN9XcIw8gbPT50zNZvqv9FGvgsMCErYC5lwPVN1670cpOpqLYV4PgU77t751CE9RsmASeB6Elwh0pAKlfxzITBx4W6aVxkl8Utlblw==
>  member2
>   member3:
> pubkey: ssh-rsa 
> B3NzaC1yc2EBIwAAAQEA2nyE+baFvebdFqiuEEjGYtLHxgduypfBg1laG8DP9Re0ln0lIJRsTw2HoB1giKRpkLXUdYkS+QVkzP0oZCNRZWuEgIuJnL8vl6c0S53UaFTNbZliIuSQLSPsEbQfIu1lQ9voZG2pwJQTj4yICnr29dSPs6ef4n8pox7hhDZSf6LBrrWWc51WYrZwXCSeDstqq53goCKLeujSZ6Ww3T7Ac17OzyhIQCl0x1w8LlcMshaczPKbFLxgLltIF8OmX9PLHuX0enFOVGKyRW66MIIyHuK65gxY/+8mjrzTw9aWOiQVvYZsjuzqBIBQy4h85ex8wF0xztR50D2ylvrbXSNl2w==
>  member3
>
>
> Currently, I have this task that deploys them and ensures they're the only 
> keys in the root user's authorized_keys list:
>
>   - name: "Ensure team pubkeys are in root's authorized_keys"
> authorized_key:
>   user: root
>   manage_dir: yes
>   exclusive: yes
>   key: |
> {% for _, user in root_ssh_public_keys.items()%}
> {% for _, key in user.items() %}
> {{ key }}
> {% endfor %}
> {% endfor %}
> tags: ssh_keys
>
> Now, what I want to be able to do is chuck this into a little role, and 
> have it be usable for any user definitions.
> So, say I had a system with the user 'example' on, and I wanted to specify 
> some keys I want that user to have in their authorized_keys list.
> I could go to that system's host_vars and add the following:
>
> example_ssh_public_keys:
>   someone:
> pubkey: ssh-rsa 
> B3NzaC1yc2EBIwAAAQEAvVO3ULx8fNGgInHCFQV6w/gEARBWyS9eA1qRaTEu4njawEjiqSGFHgPuvmgtKlft2MqbnCG3cokFKRAEOZEzy+jUMES8IQEHuSsJuZFnlUC4yzm1mI1OjJk9PwTLDD6OGJDL1gIkz37CYITbsaufS6gFrpoMBZhkVcVKk0JBnmwF/QZUD1uHKFLMtyVwvw8pzWcBcAYBBw5O6hjo2pRIX100bCdMxDrXwFp4yFiJPG6LCya4701whZpqgwk3d/RakJdZLA3pgAlVPZswz8ezj2U5PIYJl+LrUaPE57ZR/eVwNnBE7QPsKCCurIy1bLR0KXiqOmUzdzWDphYCelRurQ==
>  someone
>   someone_else:
> pubkey: ssh-rsa 
> B3NzaC1yc2EBIwAAAQEAtkScC/o1aDxaXFJdyTMhlF4UewNO/tdQf6EIYJzikSBNKECBjmvrM6bNaIkWA/AzB2dgTS0mug2aVomsBeyN8gAGfV/Wi3bO1kXuI23BmkPUn36OgE5ppQ0O2Gp8VjJaffV9EiYeEY/QlwnshAS9gfDPeTO+u5f0ZP0TZw29m+F3CKIJWPruDJJvXMkyc5qokh5kUpm0qYlhGyDi596st3Gsh/9LF/I2sEJH3LTP0gs0bWjbHN9XcIw8gbPT50zNZvqv9FGvgsMCErYC5lwPVN1670cpOpqLYV4PgU77t751CE9RsmASeB6Elwh0pAKlfxzITBx4W6aVxkl8Utlblw==
>  someone_else  
>
>
> Notice the variable name is 'example_ssh_public_keys'.
> In my task above, I need a way of dynamically defining both the 'user' 
> parameter value (shown above as 'root') and the dictionary I'm operating on 
> (shown above as 'root_ssh_public_keys').
>
> My point being I need this to be re-usable for different users.
>
> Am I going about this in a really stupid manner? What would be the best 
> way to approach this?
>
> Thanks in advance for any help!
>

-- 
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 to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/30b3408a-6526-43a0-8188-df1b8ca153cf%40googlegroups.com.
For more options, visit https://groups.g

[ansible-project] Re: How to make an item in with_items conditional?

2015-12-11 Thread Dylan Martin
I've done it by having two lists in group vars files and doing a group_by

On Friday, December 11, 2015 at 9:11:16 AM UTC-8, Marc Abramowitz wrote:
>
> Take this playbook:
>
> - hosts: mt1-dummys101
>   tasks:
> - name: Install apt packages
>   sudo: true
>   apt: pkg={{ item }}
>   with_items:
> - build-essential
> - libyaml-dev
> - python2.7-dev
> - "{{ 'silversearcher-ag' if ansible_distribution_major_version == 
> '14' else '' }}"
>
> How would I make it so that silversearcher-ag is installed only on Ubuntu 
> 14 and is omitted for other operating systems?
>
> The above gives:
>
> TASK: [Install apt packages] 
> **
> failed: [mt1-dummys101] => 
> (item=build-essential,libyaml-dev,python2.7-dev,) => {"failed": true, 
> "item": "build-essential,libyaml-dev,python2.7-dev,"}
> msg: No package matching '' is available
>
> I also tried changing the empty string `''` to `omit` but that also fails:
>
> TASK: [Install apt packages] 
> **
> failed: [mt1-dummys101] => 
> (item=build-essential,libyaml-dev,python2.7-dev,__omit_place_holder__07ef1633a8f8d1dc718ffb780b3f0e54d7f7b02a)
>  
> => {"failed": true, "item": 
> "build-essential,libyaml-dev,python2.7-dev,__omit_place_holder__07ef1633a8f8d1dc718ffb780b3f0e54d7f7b02a"}
> msg: No package matching 
> '__omit_place_holder__07ef1633a8f8d1dc718ffb780b3f0e54d7f7b02a' is available
>
> Any way to do this?
>

-- 
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 to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/771578e8-a31c-44fa-82b7-70077a19a77d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: FAILED => Missing sudo password when NO SUDO PASSWORD is needed

2015-11-11 Thread Dylan Martin
Oh, another important thing about sudo!  Don't use wildcards in a sudoers 
file if you care about the args your user passes!  You cannot specify how 
many args are allowed, so no matter how tightly you construct the wildcard, 
the user can always add more args.  Either use literal commands in the 
sudoers file or use a wrapper that sanitizes the args and have sudo call 
the wrapper.

On Tuesday, November 10, 2015 at 8:48:53 AM UTC-8, Jeff wrote:
>
> I have SUDO configured to work without passwords.
>
> This command *works just fine*:
> ansible quee -a "/usr/bin/sudo /usr/bin/apt-get update"
>
>
> This command *fails with "FAILED => Missing sudo password "*
> ansible quee -a "/usr/bin/apt-get update" --sudo
>
>
> It works if I add --ask-sudo-pass and enter a sudo password.
>
>
> I am using Ansible 1.7.2 on Debian Jessie (current stable)
>
> I want to use Ansible playbooks and expect that I will need --sudo to work 
> properly without passwords.
>
> Have I missed something obvious?
>
>
> Any help much appreciated. 
>
>
>
>

-- 
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 to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/9328abde-2cf5-4733-94a5-e161453fa3a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Role do something after handler?

2015-11-11 Thread Dylan Martin
Hi all, I have a strange one that I hope you can help me with.

I'm trying to make a role for systemd service unit files.  This is the 
newfangled replacement for good ol' sysV init scripts in Rhel7, any recent 
Fedora and a lot of other linux distros.

The workflow is supposed to go something like this.

1) edit/install a unit file, like /etc/systemd/system/myservice.service
2) run systemctl daemon-reload 
3) run systemctl enable myservice
4) run systemctl start myservice

daemon-reload tells the systemd daemon to re-read the unit files so it will 
know you changed something

In ansible, I interpret that as looking like

1) template out unit file
2) notify daemon-reload handler if unit file changed
3) service enable=true state=started name=myservice

The problem is, if I've changed the unit file, the daemon-reload runs after 
the service enable/start, so systemd doesn't know to re-read the unit file 
before trying to start/enable the service.

I could just make it run daemon-reload every time the role runs, which 
kindof sucks.  Also, if I'm installing a boatload of unit files, I'd like 
to do a daemon-reload only once to get them all.  I could make the 
daemon-reload a normal task that only runs when the template changes, but 
that means I'd be running the daemon-reload once for every unit file, which 
sucks in the case where I'm installing a boatload of them.  I looked at 
post_task, but that's not for roles.  

Does anyone know a good way to do this?

Thanks!
-Dylan

-- 
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 to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/99ffb356-ef84-4f73-8d61-322b890cb3d1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] ansible-galaxy init and metadata values

2015-10-16 Thread Dylan Martin
Hi everyone.  I expected this functionality to exist, but I can't find it 
so either it does exist and someone can gently point me toward the document 
I missed or it doesn't exist and we might want to talk about weather it 
should exist.

I expected I could write a file like ~/.ansible/galaxy-defaults.yaml that 
would look like this:

---
author: me
company: me.com
license: my license
... etc ...

and then when I run ansible-galaxy init somenewrole, my 
somenewrole/meta/main.yaml and my somenewrole/README.md files would have 
that info already templated in.

Does that make sense?  I'm a perl guy (ducks head, waits for laughter to 
subside) and I'm used to using Module::Starter where you can put values in 
~/.module-starter/config and those values get templated into new modules.

If I'm still not making sense, here's Module::Starter 


Thanks!  Sorry if I missed something in the docs that should have shown me 
how to do this!

-Dylan

-- 
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 to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/09347c87-b995-4dd4-a04d-a4c71a7ceb9f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Set vars for template from task

2014-09-03 Thread Dylan Martin
Maybe use a vars file with hash keyed to whatever your situation requires? 
 EG vars file:

---
template_var:
  site1:
name: site1
domain: example.com
  site2:  
name: site2
domain: anotherexample.com

and in template:


DocumentRoot /var/www/{{ template_vars[item][name] }}
ServerName {{ template_vars[item][name] }}{{ 
template_vars[item][domain]}}



On Monday, September 1, 2014 10:27:14 PM UTC-7, anatoly techtonik wrote:
>
> Hi,
>
> I need to set values for variable per task. Is it possible at all in 
> Ansible?
> I have this template:
>
> 
> DocumentRoot /var/www/{{name}}
> ServerName {{name}}{{domain}}
> 
>
> And I want to call it with specific name and domain parameter without 
> modifying the template.
> I tried this:
>
> - template: dest=/etc/apache2/sites-available/{{ item }}
> src=templates/virtualhost.j2
>   with_items:
> - sitename
>
> But this syntax is not good, because it requires to rewrite template to 
> use {{ item }}.
> Is it possible to avoid that?
>
> I tried moving the task into separate playbook and invoke it as 
> parametrized include.
>
> - include: roles/web/tasks/virtualhost-add.yml name=sitename domain=
> example.com
>
> This works until I add a loop with_items.
>
> - include: roles/web/tasks/virtualhost-add.yml name={{item}} domain=
> example.com
>   with_items:
> - sitename
>
> Now Ansible fails with:
>
> ERROR: [DEPRECATED]: include + with_items is a removed deprecated feature. 
>  Please update your playbooks.
>
> So, is that at all possible and what is the current best practice for 
> templating files in a loop? I thought that the most simple way is to add 
> some variables_override parameter to template module.
>

-- 
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 to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6093212f-9cd1-4124-968a-88f7dcaa3146%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] compare results of two tasks?

2014-09-03 Thread Dylan Martin
I've looked for this and haven't found it, so if this is documented 
elsewhere, I do apologize.

I want to compare the md5 sums of two copies of a list of files.  IE there 
are two locations which should have the same exact files, and I want to 
compare them.  Not all files in the two locations need to match and I have 
a list of the files that should match

- stat: foo/{{ item }}
  with-items: list_of_files
  register: foo_stat
- stat: bar/{{ item }}
  with-items: list_of_files
  register: bar_stat
- fail: msg="bar/{{ item }} doesn't match foo/{{ item }}"
  with-items: list_of_files
  when: ??

Thanks!
-Dylan

-- 
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 to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/300f8ffc-bd14-4d41-b0fe-211b7b19f05b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] checking if a dynamically selected variable is defined?

2014-08-30 Thread Dylan Martin
Hi all.

I often write plays that require extra vars.  eg "ansible-playbook user -e 
user=bob"

In that play, I'll start off with 

- fail: msg="You forgot to set the user variable"
  when: user is not defined or user == ""

And I was thinking it might be nice to write an external, reusable play 
that would be called like this:

- include: check_defined.yaml checkvar=user

and look something like this


- hosts: all
  tasks:
  - fail: msg="{{ you forgot to specify a checkvar }}"
when: checkvar is not defined or checkvar == ""
  - fail: msg="you forgot to set {{ checkvar }}"
when: ?? is not defined or ?? == ""

The first fail is just to catch myself if I include check_defined.yaml 
without setting checkvar
the second fail is the thing I actually am curious about.  The ? are 
the bits I don't know how to do.

Okay, I admit this is pretty silly, since I could write the is not defined 
checks for about 20 playbooks in the time it took to write this email.  And 
including the play is one line when the play itself ( or task) is 2.  But 
still, I think I'd understand ansible and jinja2 better if I knew the 
answer to this.  

Thanks
-Dylan

-- 
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 to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a1dd35e3-6ea3-4482-991f-e979456bdc28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Script to migrate old style vars to new style?

2013-12-05 Thread Dylan Martin
Hi all, I might be taking a big bunch of playbooks that use old style vars 
and changing them to use new style vars.  Is there a script or other 
automation that can make that easier?  Any other advice?

Thanks!
-Dylan

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.