I am having trouble figuring out how to dynamically add a provisioned host 
to inventory hosts.

Structure:
- Inventory
  - provisioning
    - group_vars
      all.yml
    hosts
- Playbooks
  - roles
    - vars
      main.yml
    - deployment
      - tasks
        main.yml
    - provision
      - tasks
        main.yml
    deploy.yml

all.yml contains variables to used in roles
hosts just contains a empty [windows] group
roles main.yml just contain a lot tasks
vars main.yml contains variables for the provision role

deploy.yml looks like this:
---
  - name: Enter variables
    hosts: localhost
    gather_facts: no
    vars_prompt:
      - name: "vsphere_username"
        prompt: "Enter vSphere Username"
        private: no
      - name: "vsphere_password"
        prompt: "Enter vSphere Password"
      - name: "vm_hostname"
        prompt: "Enter Virtual Machine Hostname"
        private: no
      - name: "vsphere_template"
        prompt: "Which application do you want to deploy?\n1- Windows 
Server 2012R2\n2- Windows Server 2016\n"
        private: no
      - name: "java_selection"
        prompt: "Which Java version do you want to deploy?\n1- JDK1.6\n2- 
JDK1.7\n3- JDK1.8\n"
        private: no
      - name: "tomcat_selection"
        prompt: "Which Tomcat version do you want to deploy?\n1- Tomcat 
7.0\n2- Tomcat 8.5\n3- Tomcat 9.0\n"
        private: no    
      - name: "Adding virtual machine hostname to inventory"
        add_host:
          name: "{{ vm_hostname }}"
          group: 
            - windows        
      - name: Deploy Virtual Machine
        roles:
        - role: provision
          vsphere_username: vsphere_username
          vsphere_password: vsphere_password
          vm_hostname: vm_hostname
          vsphere_template: vsphere_template


Add_host does not recognize the variable vm_hostname
It seems that the variables coming from prompt are not known later in the 
play?

I might have to rethink the whole process but I cant find any useful 
examples so I'm stuck :-/

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e067c958-81b8-4843-847c-fe9afc7b95cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to