I have a 2 tasks in a playbook and from task1  I have  a variable collected 
from the register output as below.

- name: Playbook to collect the actual hostname 
  hosts: server1
  become: yes
  tasks:
    - name: collect the actual hostname
      shell: 'hostname'
      register: short_name
     
    - name: collect the hostname for the next task
      set_fact: 
        reg_name: "{{ short_name.stdout_lines[-1].split('.')[1] }}"
    

- name: Playbook to test the new hostname collections 
  hosts: 127.0.0.1
  become: yes
  tasks:
    - name: print  the collected hostname
      debug:
        msg: {{reg_name  }}

 collecting  the host's shortname using set_fact is  working .  However the 
data stored using set_fact in reg_name is  not carry to the next task. 
Is there an option/module available to have the variable from one task to 
be made available to the next?


-- 
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/e414a185-f743-4618-ab14-b4449dfecf6dn%40googlegroups.com.

Reply via email to