# Operators available for use with variables in register / with\_items

**URL:** <https://forum.ansible.com/t/operators-available-for-use-with-variables-in-register-with-items/12350>\
**Category:** Ansible Project\
**Created:** [February 13, 2013, 8:59pm UTC](https://forum.ansible.com/t/operators-available-for-use-with-variables-in-register-with-items/12350 "2013-02-13T20:59:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![VK1](https://avatars.discourse-cdn.com/v4/letter/v/bbce88/32.png) [@VK1](https://forum.ansible.com/u/VK1)\
**Post date:** [February 13, 2013, 8:59pm UTC](https://forum.ansible.com/t/operators-available-for-use-with-variables-in-register-with-items/12350/1 "2013-02-13T20:59:28Z")

</div>

I am generating a list of filenames on a client to be copied back to an admin server by parsing a file via the shell module, using 'register' to store the resulting list from stdout, then iterating through fetch using 'with\_items' to copy them back to an admin server.

i.e..  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- name: fetch RPMs  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fetch: src=${item} dest=/tmp/foo  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with\_items: ${rpm\_names.stdout\_lines}

Questions:

1. Is there some documentation on available operators/variables (such as stdout\_lines) ? I got that from an example. The documentation (under Loops) mentions subkeys, which I realize would be site-specific, but the mailing list archives mention stdout\_lines as a variable. I assume there are others?

2. More specifically, what operators are available to massage strings? In this case, there is whitespace that I end up having to trim on the client via a piped command. I would be nice to say something like:

&nbsp;&nbsp;&nbsp;with\_items: ${rpm\_names.stdout\_lines.strip()}

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [February 13, 2013, 10:54pm UTC](https://forum.ansible.com/t/operators-available-for-use-with-variables-in-register-with-items/12350/2 "2013-02-13T22:54:41Z")

</div>

1.

all the variables available should generally be available in -v  
output, though IIRC stdout\_lines is not.

I agree this needs to be documented somewhere if not already 🙂

2. In templates, you can do lots. In main playbooks, you do not  
have such operators. Usually a sign something needs to be simplified  
elsewhere.

Curious what your overall playbook is that gets the rpm list and then  
has to use the rpm list, seems like the yum module would have been the  
way to go here?

---

<div class="post-metadata">

**Author:** ![VK1](https://avatars.discourse-cdn.com/v4/letter/v/bbce88/32.png) [@VK1](https://forum.ansible.com/u/VK1)\
**Post date:** [February 13, 2013, 11:40pm UTC](https://forum.ansible.com/t/operators-available-for-use-with-variables-in-register-with-items/12350/3 "2013-02-13T23:40:31Z")

</div>

> 2. In templates, you can do lots. In main playbooks, you do not  
> have such operators. Usually a sign something needs to be simplified  
> elsewhere.

Pity, this would be useful, and simpler for the register-var-cleanup use case, IMHO.

> Curious what your overall playbook is that gets the rpm list and then  
> has to use the rpm list, seems like the yum module would have been the  
> way to go here?

I'm automating an occasional build of a package that spits out two RPMs (related to an earlier thread I posted). When the build is done, I need to parse the log (from rpmbuild) to figure out what RPMs were generated, and copy those files back to a central server.

Getting this right will help with future use cases of parsing logs / stdout / stderr for strings.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [February 14, 2013, 12:38am UTC](https://forum.ansible.com/t/operators-available-for-use-with-variables-in-register-with-items/12350/4 "2013-02-14T00:38:27Z")

</div>

> I'm automating an occasional build of a package that spits out two RPMs  
> (related to an earlier thread I posted). When the build is done, I need to  
> parse the log (from rpmbuild) to figure out what RPMs were generated, and  
> copy those files back to a central server.

I see.

I'd invoke rsync via a local\_action. Keep it simple.
