# Possible bug in split\_args

**URL:** <https://forum.ansible.com/t/possible-bug-in-split-args/17908>\
**Category:** Ansible Project\
**Created:** [April 5, 2015, 3:22pm UTC](https://forum.ansible.com/t/possible-bug-in-split-args/17908 "2015-04-05T15:22:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gabriele\_Favalessa](https://avatars.discourse-cdn.com/v4/letter/g/f05b48/32.png) [@Gabriele\_Favalessa](https://forum.ansible.com/u/Gabriele_Favalessa)\
**Post date:** [April 5, 2015, 3:22pm UTC](https://forum.ansible.com/t/possible-bug-in-split-args/17908/1 "2015-04-05T15:22:54Z")

</div>

Hi all,

I’m wondering if this is the intended behavior of split\_args (ansible 1.9.0.1):

> > > from ansible.module\_utils.splitter import split\_args

> > > split\_args(‘content=" a b"’)  
> > > [u’content=" a b"']

> > > split\_args(‘content=" a\n b"’)  
> > > [u’content=" a\nb"']

i.e. if stripping the spaces after the new line is how split\_args is supposed to work.

Because spaces are stripped, this is not working for me:

- name: Create YAML from some variable  
copy: content={{ some\_variable | to\_nice\_yaml }} dest=/some/file

since the indentation of the YAML is broken once the spaces are removed.

BTW my original problem was encrypting a YAML configuration file (not an ansible playbook, just a configuration file for my application that I wanted to store encrypted before copying it to the deployment server.) To the best of my understanding it’s not possible to put a file in the vault, so I stored the YAML in an encrypted vars file instead. But then I stumbled into the reported bug, preventing me to recreate a valid human readable YAML file from the variable. My current solution is to write {{ some\_variable | to\_json }} exploiting the fact that JSON is also valid YAML but indentation is not significative at the expense of some readability.

Gabriele

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [April 6, 2015, 8:51pm UTC](https://forum.ansible.com/t/possible-bug-in-split-args/17908/2 "2015-04-06T20:51:17Z")

</div>

Hi Gabrielle, did this happen prior to 1.9.0.1?

---

<div class="post-metadata">

**Author:** ![Gabriele\_Favalessa](https://avatars.discourse-cdn.com/v4/letter/g/f05b48/32.png) [@Gabriele\_Favalessa](https://forum.ansible.com/u/Gabriele_Favalessa)\
**Post date:** [April 6, 2015, 10:15pm UTC](https://forum.ansible.com/t/possible-bug-in-split-args/17908/3 "2015-04-06T22:15:18Z")

</div>

> Hi Gabrielle, did this happen prior to 1.9.0.1?

I quickly checked 1.8 which behaves like 1.9.0.1 and 1.7 which behaves as I would expect:

> > > import ansible  
> > > ansible. **version**  
> > > ‘1.7’  
> > > from ansible.module\_utils.splitter import split\_args  
> > > split\_args(‘content=" a\n b"’)  
> > > [u’content=" a\n b"']

i.e. the spaces before ‘b’ are not removed.

Gabriele
