Defining Runtime Single variable using vars_prompt

Content of first.tf


- hosts: all
  gather_facts: False
  vars_prompt:
    - name: "Version"
      prompt: "Which version Do you want to install?"

  tasks:
    - name: Ansible prompt example.
      debug:
        msg: "{{ Version }}"
		

Defining Runtime Multiple variable using vars_prompt

Content of first.tf


---
 - hosts: myhosts
   sudo: yes

#   vars:
#     age: 27
#     myname: omkar vishwakarma
#     compname: VA

#   vars_files:
#   - "vars.yml"

   vars_prompt:
     - name: "age"
       private: no
       prompt: "Enter your age"
     - name: "myname"
       private: no
       prompt: "Enter your name"
     - name: "compname"
       private: no
       prompt: "Enter your company name"

   tasks:
   - name: "Using Debug module"
     debug:
       msg: "Name - {{ myname }} Age - {{ age }} CompanyName: {{ compname }} HOSTNAME - {{ inventory_hostname }}"
   - name: "Using register"
     shell: "find *.txt"
     args:
       chdir: /opt
     register: find_output
   - debug:
       var: find_output

Defining Runtime Multiple variable using vars_prompt

Content of first.tf


---
- name: This sets up an httpd webserver
  hosts: web
#  vars_files:
#    - "vars.yaml"
  vars_prompt:
    - name: "myname"
      private: no
      prompt: "What is your name?"

  vars:
    myname: "raj-playbook"
    mycomp: "hp-playbook"

  tasks:
  - name: Install the httpd apps
    yum: name=httpd
  - name: start the httpd service
    service: name=httpd state=started
  - debug:
      msg: System {{ myname }} has uuid {{ ansible_product_uuid }}
  - debug: msg="System {{ myname }} has uuid {{ ansible_product_uuid }}"
  - debug: msg={{ ansible_product_uuid }}
  - debug: var=ansible_product_uuid
  - debug:
      var: ansible_product_uuid
  - debug:
      var: ansible_product_uuid