# unable to send register value on remote server.

**URL:** <https://forum.ansible.com/t/unable-to-send-register-value-on-remote-server/28421>\
**Category:** Ansible Project\
**Created:** [August 25, 2018, 9:09pm UTC](https://forum.ansible.com/t/unable-to-send-register-value-on-remote-server/28421 "2018-08-25T21:09:02Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deepak\_Sharma](https://avatars.discourse-cdn.com/v4/letter/d/ac91a4/32.png) [@Deepak\_Sharma](https://forum.ansible.com/u/Deepak_Sharma)\
**Post date:** [August 25, 2018, 9:09pm UTC](https://forum.ansible.com/t/unable-to-send-register-value-on-remote-server/28421/1 "2018-08-25T21:09:02Z")

</div>



---

<div class="post-metadata">

**Author:** ![vinod93pop](https://avatars.discourse-cdn.com/v4/letter/v/ea5d25/32.png) [@vinod93pop](https://forum.ansible.com/u/vinod93pop)\
**Post date:** [August 26, 2018, 3:44am UTC](https://forum.ansible.com/t/unable-to-send-register-value-on-remote-server/28421/2 "2018-08-26T03:44:47Z")

</div>

> * * *
> 
> - hosts: all  
> gather\_facts: true  
> sudo: true  
> tasks:
> 
> - name: capture linux\_os  
> shell: “{{ item }}”  
> register: prepatch  
> with\_items:
> 
> - ‘uname -a’
> 
> - ‘cat /etc/resolv.conf’
> 
> - name: create directory  
> file: path=/tmp/{{petch1}} state=directory

What is the error screen.-also petch1 is nowhere mentioned .whatever given inside curly braces it taken as variable

---

<div class="post-metadata">

**Author:** ![Badraj\_Angirekula](https://avatars.discourse-cdn.com/v4/letter/b/a4c791/32.png) [@Badraj\_Angirekula](https://forum.ansible.com/u/Badraj_Angirekula)\
**Post date:** [August 27, 2018, 9:27am UTC](https://forum.ansible.com/t/unable-to-send-register-value-on-remote-server/28421/3 "2018-08-27T09:27:15Z")

</div>

Hi all,

please help me.

Build ec2 instances with attaching multiple tags names :-  
For example- I have launched one ec2 instance with tag name “websever1” the next builds of ec2 instances should start with tag name webserver2 , webserver3 … automatically.

Note: No two ec2 instances have same tag name.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [August 27, 2018, 3:41pm UTC](https://forum.ansible.com/t/unable-to-send-register-value-on-remote-server/28421/4 "2018-08-27T15:41:38Z")

</div>

Your copy syntax is invalid, i'm guessing this is what you want:

&nbsp;&nbsp;&nbsp;copy: content={{ prepatch.stdout }} dest=/tmp/{{petch1}}-prepatch.txt

It also looks wrong as prepatch is a list and does not have a stdout  
but a .results, with each item having a stdout

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [August 27, 2018, 3:45pm UTC](https://forum.ansible.com/t/unable-to-send-register-value-on-remote-server/28421/5 "2018-08-27T15:45:51Z")

</div>

sorry, missing 1/2 of previous, here would be the final 'copy':

- copy: content={{ prepatch.results|selectattr('stdout')|join('\n') }}  
dest=/tmp/{{petch1}}-prepatch.txt

This will put into the destination file the output fo both commands  
separated by a new line, which I think is your intention.

---

<div class="post-metadata">

**Author:** ![Deepak\_Sharma](https://avatars.discourse-cdn.com/v4/letter/d/ac91a4/32.png) [@Deepak\_Sharma](https://forum.ansible.com/u/Deepak_Sharma)\
**Post date:** [August 27, 2018, 5:21pm UTC](https://forum.ansible.com/t/unable-to-send-register-value-on-remote-server/28421/6 "2018-08-27T17:21:31Z")

</div>

Hi Brian ,

Still getting errors.

[root@station1 ansible]# ansible-playbook c2.yml  
[WARNING]: While constructing a mapping from /etc/ansible/c2.yml, line 5, column 7, found a duplicate dict key (register). Using last  
defined value only.

PLAY [localhost] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [setup] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost]

TASK [capture linux\_os] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [localhost] =\> (item=uname -a)  
changed: [localhost] =\> (item=cat /etc/resolv.conf)

TASK [creating db\_inventory\_dir] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost]

TASK [copy] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [localhost]: FAILED! =\> {“failed”: true, “msg”: “the field ‘args’ has an invalid value, which appears to include a variable that is undefined. The error was: ‘petch1’ is undefined\n\nThe error appears to have been in ‘/etc/ansible/c2.yml’: line 17, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n state: directory\n - copy: content={{ prepatch.results|selectattr(‘stdout’)|join(‘\n’) }} dest=/tmp/{{petch1}}-prepatch.txt\n ^ here\nWe could be wrong, but this one looks like it might be an issue with\nmissing quotes. Always quote template expression brackets when they\nstart a value. For instance:\n\n with\_items:\n - {{ foo }}\n\nShould be written as:\n\n with\_items:\n - "{{ foo }}"\n”}  
to retry, use: --limit @/etc/ansible/c2.retry

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
localhost : ok=3 changed=1 unreachable=0 failed=1

---

<div class="post-metadata">

**Author:** ![Deepak\_Sharma](https://avatars.discourse-cdn.com/v4/letter/d/ac91a4/32.png) [@Deepak\_Sharma](https://forum.ansible.com/u/Deepak_Sharma)\
**Post date:** [August 27, 2018, 5:28pm UTC](https://forum.ansible.com/t/unable-to-send-register-value-on-remote-server/28421/7 "2018-08-27T17:28:06Z")

</div>

Sort out, it’s working now, Thanks Brian for your help.

---

<div class="post-metadata">

**Author:** ![Deepak\_Sharma](https://avatars.discourse-cdn.com/v4/letter/d/ac91a4/32.png) [@Deepak\_Sharma](https://forum.ansible.com/u/Deepak_Sharma)\
**Post date:** [August 27, 2018, 5:47pm UTC](https://forum.ansible.com/t/unable-to-send-register-value-on-remote-server/28421/8 "2018-08-27T17:47:08Z")

</div>

Guys i need to store value of commands at remote servers.which i run with shell module

but the value is not coming up.  
it is coming line that

[root@station2 petch2]# cat prepatch.txt  
[{“\_ansible\_parsed”: true, “changed”: true, “stdout”: “Linux [station2.example.com](http://station2.example.com) 3.10.0-327.el7.x86\_64 #1 SMP Thu Oct 29 17:29:29 EDT 2015 x86\_64 x86\_64 x86\_64 GNU/Linux”, “\_ansible\_item\_result”: true, “warnings”: , “delta”: “0:00:00.007163”, “stdout\_lines”: [“Linux [station2.example.com](http://station2.example.com) 3.10.0-327.el7.x86\_64 #1 SMP Thu Oct 29 17:29:29 EDT 2015 x86\_64 x86\_64 x86\_64 GNU/Linux”], “end”: “2018-08-27 13:44:59.407023”, “\_ansible\_no\_log”: false, “start”: “2018-08-27 13:44:59.399860”, “cmd”: “uname -a”, “item”: “uname -a”, “stderr”: “”, “rc”: 0, “invocation”: {“module\_name”: “command”, “module\_args”: {“warn”: true, “executable”: null, “\_uses\_shell”: true, “\_raw\_params”: “uname -a”, “removes”: null, “creates”: null, “chdir”: null}}}, {“\_ansible\_parsed”: true, “changed”: true, “stdout”: “# Generated by NetworkManager\nsearch localdomain [example.com](http://example.com)\nnameserver 192.168.1.2”, “\_ansible\_item\_result”: true, “warnings”: , “delta”: “0:00:00.008031”, “stdout\_lines”: [“# Generated by NetworkManager”, “search localdomain [example.com](http://example.com)”, “nameserver 192.168.1.2”], “end”: “2018-08-27 13:45:00.090280”, “\_ansible\_no\_log”: false, “start”: “2018-08-27 13:45:00.082249”, “cmd”: “cat /etc/resolv.conf”, “item”: “cat /etc/resolv.conf”, “stderr”: “”, “rc”: 0, “invocation”: {“module\_name”: “command”, “module\_args”: {“warn”: true, “executable”: null, “\_uses\_shell”: true, “\_raw\_params”: “cat /etc/resolv.conf”, “removes”: null, “creates”: null, “chdir”: null}}}][root@station2 petch2]#

---

<div class="post-metadata">

**Author:** ![Wendell\_MacKenzie](https://avatars.discourse-cdn.com/v4/letter/w/c77e96/32.png) [@Wendell\_MacKenzie](https://forum.ansible.com/u/Wendell_MacKenzie)\
**Post date:** [August 27, 2018, 5:47pm UTC](https://forum.ansible.com/t/unable-to-send-register-value-on-remote-server/28421/9 "2018-08-27T17:47:43Z")

</div>

deepak from BEA Systems??

---

<div class="post-metadata">

**Author:** ![Deepak\_Sharma](https://avatars.discourse-cdn.com/v4/letter/d/ac91a4/32.png) [@Deepak\_Sharma](https://forum.ansible.com/u/Deepak_Sharma)\
**Post date:** [August 27, 2018, 5:49pm UTC](https://forum.ansible.com/t/unable-to-send-register-value-on-remote-server/28421/10 "2018-08-27T17:49:07Z")

</div>

Nope
