Hi Racke , 
Actually Controller/Tower not in our controll , different team handling , 
only we have controll on remote machine and playbook .
Even i can't access tower also . 

Can u pls help me to know how we pass host variable from one play to other 
? 
i need to pass hostname from one play to other play 


- hosts: all
  tasks:
  - name: fetch tar file from remote to local machine 
    fetch:
        src: /tmp/config.tar
        dest: /tmp/
        flat: ture
  - name: Register hostname
    shell: hostname
    register: play1
  - name: display message
    debug: 
       msg: "{{play1.stdout}}"
  - name: Register dummy host with variable
    add_host:
       name: "DUMMY_HOST"
       play1_new: "{{ play1.stdout }}"
     
 
         
- hosts: localhost
  tasks: 
  - name: Pass the host variable from remote to local 
    shell: cat "{{ hostvars['DUMMY_HOST']['play1_new']}} |tail -1"
    register: play2_result
  - name: Display from localhost
    debug:
      msg: "{{ play2_result.stdout }}"
    

Error:  
fatal: [DUMMY_HOST]: UNREACHABLE! => {

"changed": false, 

"msg": "Failed to connect to the host via ssh: ssh: Could not resolve 
hostname dummy_host: Name or service not known", 

"unreachable": true

}







 


On Wednesday, February 26, 2020 at 2:21:00 PM UTC+5:30, Stefan Hornburg 
(Racke) wrote:
>
> On 2/26/20 8:24 AM, Janmejaya Swain wrote: 
> > Hi ,  
> > 
> > 1. I have multiple json as well as j2 files , Need to generate multiple 
> config files by using template module.  
> > 2.  In fetch module . fetch the files with including host name in path . 
> How we can avoid this hostname in path ? 
> >      Ex:  
> > - name: fetch tar file from remote to local machine  
> >     fetch: 
> >         src: /tmp/tts_config.tar 
> >         dest: /tmp/ 
> >         flat: ture 
> > 
> > and files are present in following path in controller  
> > /tmp/namwrncld1135.nam.nsroot.net/tmp/tts_config.tar 
> > namwrncld1135.nam.nsroot.net is remote machine  
> > Can anyone please  help here. so that i greatfull to u . 
> > 
> > Thanks  
> > 
>
> It eludes me why you don't install rsync on the Ansible controller and use 
> synchronize module as recommended. 
>
> Regards 
>          Racke 
>
> >   
> > 
> > On Wednesday, February 19, 2020 at 7:42:56 PM UTC+5:30, Janmejaya Swain 
> wrote: 
> > 
> >     Hi , 
> > 
> >     Can any one please  help on this, which is very appreciable.  . 
> > 
> >     --- 
> >      - hosts: all 
> >        remote_user: root 
> >        vars_files: 
> >               - json/UAT.json 
> > 
> >        tasks: 
> >          - name: Generate configGen files  
> >            template: 
> >              src: /template/test.j2 
> >              dest: /properties/test.properties 
> >              remote_src: yes 
> >              template_host: < host ip > 
> >            
> > 
> >     Error: 
> > 
> >     ERROR! vars file /template/test.j2 was not found 
> > 
> >     15 
> > 
> >     Could not find file on the Ansible Controller. 
> > 
> >     16 
> > 
> >     If you are using a module and expect the file to exist on the 
> remote, see the remote_src option 
> > 
> > 
> >     In same way it showing it showing json/UAT.json was not found. 
> > 
> > 
> >     NOTE: Can you please help on it and we are using ansible 2.9.  
> > 
> > -- 
> > 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 
> > [email protected] <javascript:> <mailto:
> [email protected] <javascript:>>. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/ansible-project/e1d10a4c-dcaa-48af-92ef-25a1504e56c3%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/e1d10a4c-dcaa-48af-92ef-25a1504e56c3%40googlegroups.com?utm_medium=email&utm_source=footer>.
>  
>
>
>
> -- 
> Ecommerce and Linux consulting + Perl and web application programming. 
> Debian and Sympa administration. Provisioning with Ansible. 
>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a26a1b29-9312-48e4-93a3-e85628f1df65%40googlegroups.com.

Reply via email to