Re: [ansible-project] delegate_to /one member/ of a group

2015-11-18 Thread Elliott Barrere
Okay, just getting back to this.  I have this in my site.yaml file in 
group_vars:

rwdc_server: '{{groups.rwdcs|random}}'


but it appears that the rwdc_server variable gets a different domain 
controller from the group each time it's accessed (sometimes it's the same 
one, but not always).  I need the value to be consistent so I can run a 
series of commands on the same box.  Is this possible?

I'd rather not pin it to a single box (with e.g. {{groups.rwdcs[0]}}), for 
basic load balancing & HA...

-- 
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/92ca658f-d19c-4e3b-aa94-694ebf83b456%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Problem looping over JSON data returned from URI call

2015-11-18 Thread Brian Green
Try using from_json filter

http://docs.ansible.com/ansible/playbooks_filters.html#filters-for-formatting-data
https://gist.github.com/lxhunter/45fb119c0128600158d8

On Tuesday, November 17, 2015 at 12:09:30 PM UTC-6, Andris Bjornson wrote:
>
> Hello - I have a question about looping over json data I’ve received from 
> calling a REST api using the URI module.  I’ve been tearing my hair out 
> over the last several days trying to sort this out…and have googled 
> extensively - but haven’t gotten anywhere.  I think it has to do with the 
> difference between a dict, and array, and a list…but i’m new-ish to ansible 
> and not understanding what i’m doing wrong.  Any help greatly appreciated.
>
> Here is the data returned and registered by the URI module call.  Lets say 
> I registered it in a variable called "registered_variable"  
> https://gist.github.com/andris/77dcdfd17eef0cdd3563
>
> I can access individual items from the array by doing this: 
>  registered_variable.json.data[1]
>
> I can access attributes of individual items from the array by doing this: 
>  registered_variable.json.data[1].name
>
> But whenever I try to use with_dict or with_items to loop over 
> registered_variable.json.dataI just get an "item is undefined error" 
> (for example)
>
> - debug:
> msg: "{{item.name}} is the name of the device"
> with_dict: "{{registered_variable.json.data}}"
>
> I also tried first storing the object in a variable first:
>
> - set_fact:
> devices: "{{ registered_variable.json.data }}"
> - debug:
> msg: "{{item.name}} is the device name"
> with_dict: devices
>
>
> I am running on the latest dev from checkout (2.0.0)
>
> Any suggestions?
>
> Thanks in advance!
>

-- 
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/d96a03d4-4964-46dc-bf1c-38f950314dbb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] How to define host var and append values to it from task

2015-11-18 Thread Elad Yosef
Hi all,I'm now to ansible 

I have host variable

locked_domains:

and I'm trying to append values to it from task

- set_fact: locked_domains="{{ locked_domains + item.ID }}"
  with_items: "{{ domains.json }}"


Can anyone 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/dc4428bc-d1d0-4698-8e5b-a9bfe463d263%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] How can append values into host variable

2015-11-18 Thread Elad Yosef
Hi all,

I'm very new to ansible and sorry if the question is too easy


I have defined host_var

locked_domains:

And I want to append values to it from a task

- set_fact: locked_domains="{{ locked_domains + item.ID }}"
  when: {{item.state}} == "some_cond"
  with_items: "{{ domains.json }}"


where domains.json is an array of objects

I get the following error

fatal: [localhost] => Failed to template locked_domains="{{ locked_domains 
+ item.ID }}": an unexpected type error occurred. Error was unsupported 
operand type(s) for +: 'NoneType' and 'str'

FATAL: all hosts have already failed -- aborting

Please advise

Thanks

Elad

-- 
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/9551f192-a165-4537-9542-df8d82154e70%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Copying a remote MySQL Database

2015-11-18 Thread Steven Parsons
I am wondering if anyone has copied a MySQL database from a location and 
then restored it locally using Ansible? I thought I had it figured out with 
the following syntax, but for some reason its failing.

- name: Install python-mysqldb
  apt: name=python-mysqldb state=latest

- name: Copy MySQL Database
  mysql_db: login_host=onthe.web.net login_user=someone login_password=cheese 
state=dump name=cheese target=/tmp/cheese.sql
  mysql_db: state=import name=cheese target=/tmp/cheese.sql

Any help would be appreciated.

Steven

-- 
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/9cf850d5-d844-49da-9e2a-672f14483513%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Module Parameter Defaults (or Module Shortcut/Alias) ?

2015-11-18 Thread Matt Martz
This is technically feasible now, but it isn't specifically ansible
functionality, instead it is YAML functionality.  Here is an example
playbook that displays how this works:

---
- hosts: all
  gather_facts: false
  vars:
- uri_defaults: &URI_DEFAULTS
url: "http://httpbin.org/get";
method: GET
  tasks:
- uri:
<< : *URI_DEFAULTS
status_code: 200

- uri:
<< : *URI_DEFAULTS
status_code: 201
  ignore_errors: true

- uri:
<< : *URI_DEFAULTS
url: "http://httpbin.org/status/201";
status_code: 201


This uses YAML aliases, anchors, and merge functionality.



On Tue, Nov 17, 2015 at 7:46 AM,  wrote:

> Hello List,
>
> is it possible to set defaults for the parameters of a module? Or create a
> shortcut/alias?
>
> For example if I have to execute several uri calls with the same url. In
> case they are next
> to each other you can use a loop but otherwise you have to specify the
> same parameters
> again and again.
>
>
> Thanks,
> Dennis Benzinger | hybris
>
> --
> 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/2988e835-8764-49e7-8779-dc96fee401e0%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
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...@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/CAD8N0v8LBJQU_uUQFxh%2B6PA%2BGar-bC4N7LPcu0STVebcryTSJQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Setup facts: ansible_default_ipv4 is empty, even when interface is active with an ip address

2015-11-18 Thread Joanna Delaporte
This might just be a configuration issue with my host. I'm still working on 
bootstrapping it to be my new control host.  I also just realized that AWS 
EC2 hosts give their internal addresses, not public, so default ipv4 won't 
always do what I need.

My goal is to fetch a set of ssh public_key files gathered from remote 
hosts, and name them with user + the hosts' public ip addresses.  Is there 
a way to extract the ips from a group of hosts? I am ending up with one 
file rather than a file for each host when I use the following:

My task:

- name: copy new keys back to repo
fetch: "src=/home/ansible/.ssh/id_rsa.pub
dest=/home/ansible/public_keys/ansible_{{item}}
flat=yes"
with_items:
- '{{ hosts }}'

On the command line I specify --extra-vars "hosts=ipaservers" and end up 
with one file named ansible_ipaservers with only one key in it. I'm hoping 
to end up with something like ansible_52.x.x.x, ansible_192.x.x.x, 
ansible_176.x.x.x files instead, each with the ansible user's key on that 
host.

On Wednesday, November 18, 2015 at 10:27:46 AM UTC-6, Joanna Delaporte 
wrote:
>
> I am writing a playbook where I want to name a file including the 
> ipaddress. However, my default ipv4 in the facts is empty, even though my 
> interface is active and has a static ip. My target machine is CentOS 7.1, 
> and my ansible version is 1.9.3.  
>
> *"ansible_default_ipv4": {}, *
>  "ansible_default_ipv6": {
> "address": "REDACTED", 
> "gateway": "REDACTED", 
> "interface": "enp5s0", 
> --break--
>  "ansible_enp5s0": {
> "active": true, 
> "device": "enp5s0", 
> "ipv4": {
> *"address": "REDACTED", *
> "netmask": "255.255.255.0", 
> "network": "REDACTED"
>
>

-- 
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/78fbffa3-cbe9-4968-9825-8f8d8920b931%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] performing a local task on every (remote) loop iteration - is that even possible?

2015-11-18 Thread nusenu
solution:

https://docs.ansible.com/ansible/playbooks_delegation.html#delegation

-- 
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/564CBAD5.2040207%40openmailbox.org.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Help with callback to tower from AWS auto scaling script

2015-11-18 Thread Adrian Black
Trying to put the bits together to get an auto scaling group in aws to come 
on line and create a vm that does a callback to tower for provisionment.

The bit im getting stuck with is the callback part

According 
to http://docs.ansible.com/ansible-tower/2.2.0/html/userguide/job_templates.html

you use the /usr/share/awx/request_tower_configuration.sh script as a basis

this script looks like it takes arguments so should be called somethig like 

./scripts/request_tower_configuration.sh  ansible.myco.com 
84e2d9d26c5977c1b12eb353f1a97aa1 94

I have seen the launch config script snippet like

- name: create launch config
 ec2_lc:
   name: "{{ site_prefix }}-lc"
...
   user_data: "{{ lookup('file', 
'./scripts/request_tower_configuration.sh')}}"

that takes the contents of that file as pastes it as a blob in the 
user_data field on a created vm but without the arguments you need its 
useless.

i did try this too but that doesnt work
user_data: "{{ lookup('file', './scripts/site_callback.sh') 
 ansible.idg.co.uk 84e2d9d26c5977c1b12eb353f1a97aa1 94 }}"


anyone got a working example of how this works?

thanks










-- 


This message is private and confidential and for the exclusive use of the 
intended recipient(s). If you receive this email in error, please notify 
the sender immediately and delete all copies from your system. If you are 
not the intended recipient disclosure, distribution, copying or use of this 
communication is strictly prohibited. Any views or opinions presented in 
this email are solely those of the author and do not necessarily represent 
those of IDG UK. Clients and suppliers can view our full terms and 
conditions at www.idg.co.uk/terms-and-conditions/


IDG Communications Ltd. Company Reg No: 1197840. Registered in England and 
Wales.

-- 
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/b683524f-0ffe-4ad3-b52a-c2d66126c40a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] New to Ansible - how to setup a practice environment

2015-11-18 Thread Adrià
On Wed, Nov 18, 2015 at 02:51:50AM -0800, Paul Davies wrote:

[...]
>My question is simply - how do you practice? Am I best creating other
>VirtualBox machines on the same host and trying to control those, or am I
>best creating other VMs on my CentOS VM and controlling those? If the
>latter - then am I best using VirtualBox again or Vagrant (new to that
>too) to create the target VMs?
>Or am I best doing something completely different?
>Any advise welcome!
>thanks
>Paul
> 

Hi Paul,

my suggestion is that you practice in a test environment such as a
VirtualBox VM as you told. Otherwise, using Vagrant is a good choice
as well (see [1]).

You may have a look to Ansible Examples [0] and let the magic happens,
and then try to adapt those examples to your needs.

Internet is plenty of Ansible manuals, so you could start with a basic
"ansible -m ping localhost" style manual [1] and then become a ninja
like OpenShift guys [2].

Hope it helps!

[0] https://github.com/ansible/ansible-examples
[1]
https://adamcod.es/2014/09/23/vagrant-ansible-quickstart-tutorial.html
[2] https://github.com/openshift/openshift-ansible

-- 
Adrià García-Alzórriz
0x09494C14
¡Una sopa de tu propio chocolate! 

-- 
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/20151118172151.GA28492%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: PGP signature


[ansible-project] Problem with function to merge nested dictionaries

2015-11-18 Thread Max Lock
Hi All,

 I'm using ansible 1.9.3, and want to merge two nested dicts to template to 
a config file. I've written a combine function similar to whats in 2.n.n. 
The problem is that the merged dictionary appears to be unicode preventing 
me from iterating over it in the template. This is the combine function:

def combine(original, update):
for key, value in original.items():
if not key in update:
update[key] = value
elif isinstance(value, dict):
combine(value, update[key])

return update

class FilterModule(object):

def filters(self):
return {
'combine': combine,
}

My testcase is this.

---
- hosts: all
  gather_facts: False
  vars:
a:
  first:
second: 'foo'
b:
  first:
third: 'bar'

  tasks:
- set_fact: c="{{ a | combine(b) }}"
- debug: var=c
- debug: msg="{% print a.__class__ %}"
- debug: msg="{% print b.__class__ %}"
- debug: msg="{% print c.__class__ %}"...

Which when run produces:

PLAY [all] 


TASK: [set_fact c="{{ a | combine(b) }}"] 
*
ok: [localhost]

TASK: [debug var=c] 
***
ok: [localhost] => {
"var": {
"c": {
"first": {
"second": "foo",
"third": "bar"
}
}
}
}

TASK: [debug msg=""] 
**
ok: [localhost] => {
"msg": ""
}

TASK: [debug msg=""] 
**
ok: [localhost] => {
"msg": ""
}

TASK: [debug msg=""] 
**
ok: [localhost] => {
"msg": ""
}

PLAY RECAP 

localhost  : ok=5changed=0unreachable=0failed=0


Notice that both parent dicts are of type dict, but the merged child is of 
type unicode? Any help much appreciated. :)

 -Cheers Max.

-- 
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/c393c455-724e-4ae2-8ac2-7321d73172e2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] New to Ansible - how to setup a practice environment

2015-11-18 Thread Paul Davies
Hi all

I am new to Linux, Ansible and CI/Devops in general having come from a 
Windows/SQL background


I am trying to learn Ansible, My requirements are to control it from a 
CentOS machine and control other CentOS/Solaris machines and possibly 
Win2008R2 too


on my Windows desktop, I have created a CentOS VirtualBox and installed 
Ansible via yum. I have no other remote machines to use as yet


My question is simply - how do you practice? Am I best creating other 
VirtualBox machines on the same host and trying to control those, or am I 
best creating other VMs on my CentOS VM and controlling those? If the 
latter - then am I best using VirtualBox again or Vagrant (new to that too) 
to create the target VMs?

Or am I best doing something completely different?

Any advise welcome!

thanks
Paul

-- 
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/f43d96d5-f6b9-4a6d-b1ec-56c952404a1a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Unstable network

2015-11-18 Thread karljohanreite
Hi,

We are facing a situation where we have servers with slow and unstable 
network connections. This is because the network is provided by GSM modems 
onboard moving vessels.

Does anyone know how Ansible will handle a situation where the network may 
fall out during deployment? Will the deployment happen in a somewhat atomic 
way, or will the deployment be abruptly aborted if the ssh channel 
terminates?

I appreciate any insights or suggestions on this.

Thank you.

kj

-- 
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/46578438-941d-468d-aa52-0269b6a6a962%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Using ansible inside docker

2015-11-18 Thread lewis
Does anyone use ansible inside docker? We have for a while now, and we've 
had nothing but trouble with ansible's service module and docker's 
inability to run upstart.

Ansible 1.9 onwards seems to prefer using initctl over service, which in 
Docker is symlinked to /bin/true and so fails silently. Whereas service 
works fine, since it will default to sysv scripts if upstart isn't 
available. Is there a specific reason that ansible prefers initctl? 

Is it worth putting in a PR to detect this use-case specifically (initctl 
being symlinked to bin/true)? Or would a better fix be to let the user 
explicitly define a service module somehow?

-- 
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/55015913-52b9-4369-9e75-145d1cf54628%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Setup facts: ansible_default_ipv4 is empty, even when interface is active with an ip address

2015-11-18 Thread Joanna Delaporte
I am writing a playbook where I want to name a file including the 
ipaddress. However, my default ipv4 in the facts is empty, even though my 
interface is active and has a static ip. My target machine is CentOS 7.1, 
and my ansible version is 1.9.3.  

*"ansible_default_ipv4": {}, *
 "ansible_default_ipv6": {
"address": "REDACTED", 
"gateway": "REDACTED", 
"interface": "enp5s0", 
--break--
 "ansible_enp5s0": {
"active": true, 
"device": "enp5s0", 
"ipv4": {
*"address": "REDACTED", *
"netmask": "255.255.255.0", 
"network": "REDACTED"

-- 
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/4adec00b-274f-414b-bfee-53a5b80854a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] checking java process

2015-11-18 Thread skr989
I have the below play to check if JBoss application server is RUNNING. I am 
getting the message "JBoss Process is running on localhost" 
(inventory_hostname = localhost) even when JBoss is DOWN. Am I doing 
anything wrong here?


  tasks:   
   - name: Check JBOss java process
 shell: ps -ef | grep java | grep "jboss.server"
 register: jboss_java_process
 ignore_errors: false
  
   - debug: msg="JBoss Process is running on {{ inventory_hostname }}"
 when: jboss_java_process.stdout.find("jboss.server") != -1


-SKR

-- 
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/d5b6df54-73cd-4669-8684-0fe9c6c60d82%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Spaces in URL and file name with get_url and unarchive

2015-11-18 Thread Nathan Sowatskey
Toshio

This is very helpful, thank you very much.

My vote is for is an option that turns it on explicitly.

My reasoning is as follows:

 - That would obviate the need to change variable values explicitly, which may 
anyway not be possible if the variable value is external and not under the 
control or definition of the playbook, e.g. an environment variable or a 
variable generated by another system at runtime.
 - It would support “intelligent” behaviour, and it is reasonable to expect 
tools such as Ansible to be intelligent and do such things for you.
 - I find the current behaviour and the lack of an option surprising, 
obviously, so there is an element of failing to pass the test of “least 
surprise”.

Regards

Nathan

> On 17 Nov 2015, at 20:56, Toshio Kuratomi  wrote:
> 
> tldr; url escape your url string, replace the spaces with %20, and it
> will work.  You can use the urlencode jinja2 filter if you like but it
> will change how you store the elements of your url slightly:
> 
> - vars:
>pydev_url_scheme: http
>pydev_url: freefr.dl.sourceforge.net/project/pydev/pydev/PyDev 4.4.0/
>pydev_bundle: PyDev 4.4.0.zip
>  tasks:
>- get_url: url="{{pydev_url_scheme}}://{{ pydev_url
> |urlencode()}}/{{ pydev_bundle|urlencode() }}" dest=/tmp/pydev
> 
> In depth:
> 
> I can duplicate and the problem would be solved by doing a
> urllib.quote of the path element of the url string(which replaces
> spaces with "%20")  Not sure whether we should do that or not.  It
> would be a change in behaviour that breaks things for people who
> already escape their url.  In my experience, tools commonly accept
> spaces and escape if they are not already escaped.  Libraries commonly
> force the user to escape themselves.
> 
> Experimenting shows that curl does not automatically escape spaces
> (although its interaction with this server is somewhat surprising...
> it's returning a 302 to a page saying the mirror failed rather than a
> 404).  Manually changing the spaces to %20 is required.
> 
> Looks like wget attempts to be smart.  I haven't worked out the exact
> algorithm it's using but it seems to automatically escape spaces.  It
> escaped a percent not followed by a number.  But it did not escape a
> percent followed by a number.  So with wget, both
> "http://freefr.dl.sourceforge.net/project/pydev/pydev/PyDev 4.4.0/"
> and "http://freefr.dl.sourceforge.net/project/pydev/pydev/PyDev%204.4.0/";
> work but if you have a file named ugly%42file.html, the url you'd have
> to create for that would have to manually escape the percent sign like
> this:  ugly%2542file.html.
> 
> So for ansible... we could take a few different paths i think:
> * Do nothing -- we match curl's behaviour here.  People can just use %
> escaping for the urls they specify and the jinja iflter helps with
> that.
> * Do something like wget and escape spaces and certain uses of
> percents.  This will break backwards compat but probably for only a
> few people.
> * Add a parameter to get_url to let the user specify whether we should
> escape or not defaulting to no escape.  this is fully backwards
> compatible and lets the user choose whether to escape or not.
> 
> Willing to hear some discussion and a pull request to implement a
> change based on that.
> 
> -Toshio
> 
> On Tue, Nov 17, 2015 at 5:13 AM, Nathan Sowatskey
>  wrote:
>> Hi Toshio
>> 
>> Apologies for the lack of detail, and thanks for following up.  The Ansible
>> version is 1.9.4.
>> 
>> The playbook in question is here:
>> 
>> https://github.com/DevOps4Networks/ansible-eclipse
>> 
>> See this section at line 207 of tasks/eclipse.yml:
>> 
>> - name: eclipse | Get eclipse Pydev plugin bundle
>> 
>>  #TODO Test get_url again and raise a bug about spaces in the URL
>> 
>>  #shell: mkdir -p /tmp/pydev; cd /tmp/pydev; wget "{{ pydev_url }}/{{
>> pydev_bundle }}" -O pydev.zip
>> 
>>  get_url: url="{{ pydev_url }}/{{ pydev_bundle }}" dest=/tmp/pydev
>> 
>>  when: eclipse_plugins_pydev_enabled and eclipse_plugins_enabled
>> 
>> 
>> What I see with the get_url as shown above is :
>> 
>> failed: [localhost] => {"dest": "/tmp/pydev", "failed": true, "response":
>> "HTTP Error 404: Not Found", "state": "absent", "status_code": 404, "url":
>> "http://freefr.dl.sourceforge.net/project/pydev/pydev/PyDev 4.4.0/PyDev
>> 4.4.0.zip"}
>> 
>> When I comment out the get_url, and instead use the shell command, I get:
>> 
>>virtualbox-iso:  REMOTE_MODULE command mkdir -p /tmp/pydev;
>> cd /tmp/pydev; wget
>> "http://freefr.dl.sourceforge.net/project/pydev/pydev/PyDev 4.4.0/PyDev
>> 4.4.0.zip" -O pydev.zip #USE_SHELL
>>virtualbox-iso:  EXEC ['/bin/sh', '-c', 'mkdir -p
>> $HOME/.ansible/tmp/ansible-tmp-1447762454.08-148319008390996 && chmod a+rx
>> $HOME/.ansible/tmp/ansible-tmp-1447762454.08-148319008390996 && echo
>> $HOME/.ansible/tmp/ansible-tmp-1447762454.08-148319008390996']
>>virtualbox-iso:  PUT /tmp/tmpVCp9bn TO
>> /home/vagrant/.ansible/tmp/ansible-tmp-1447762454.08-1483190083909