VMware Aria Automation Tools

 View Only
  • 1.  vRA 8.7 - Ansible and Extra variables

    Posted Apr 27, 2022 11:34 PM

    I feel like this should be the EASY part, but - we are calling an Ansible playbook to create username/password on a Linux box.

    Running the playbook from another machine as such works fine:
    ansible-playbook /etc/ansible/roles/foo/userplaybook.yaml -l IPADDRESS, -e "user=Username password=Password" -u logonusername -b

    But with the following in our Template...
    username: logonusername
    password: logonusernamepassword
    playbooks:
     provision:
      - /etc/ansible/roles/foo/userplaybook.yaml --extra-vars "user=Username password=Password!"

    We get the following error, as if it is not passing the extra variables at all:

    FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'user' is undefined\n\nThe error appears to be in '/etc/ansible/roles/foo/tasks/main.yml

    We've tried sending the -e as above, and as JSON format, with extra single quotes, who knows how many other things.
    Any ideas where the problem lies?  The fact we're calling the playbook is a good start, but from there, this looks like it's supposed to be the easy part, yet somehow we're not sending what we think we are?



  • 2.  RE: vRA 8.7 - Ansible and Extra variables

    Posted Jul 10, 2022 03:42 PM

    We encounter the same problem.

    Everything works when trying to pass the vars from Ansible server, but when adding the -e flag (or --extra-vars), the input doesn't get passed into the playbook.

    Anyone manages to get it to work?



  • 3.  RE: vRA 8.7 - Ansible and Extra variables

    Posted Jul 12, 2022 05:22 AM

     

    Hi, 

    Can you try passing the vars in the JSON string format, see below:

    ansible-playbook release.yml --extra-vars '{"version":"1.23.45","other_variable":"foo"}'
    ansible-playbook arcade.yml --extra-vars '{"pacman":"mrs","ghosts":["inky","pinky","clyde","sue"]}'

    Referred ansible documentation: https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#json-string-format

     



  • 4.  RE: vRA 8.7 - Ansible and Extra variables

    Posted Jul 29, 2022 07:46 AM

    Anyone come across a solution?  I'm coming across the same issue.  Had it with 8.6.2 and still existing with 8.8.1.  In my case, we are in the middle of migrating between Ansible Tower (v3.8.3) to Ansible Automation Platform (v2.1.1).  Extra variables are successfully passed to our old Ansible Tower instance.  We use the same template (blueprint) but one newer version pointing to our new Ansible integration pointing to AAP.  So the Ansible code in the template is the same otherwise.  Extra variables are & have been in JSON format.  For whatever reason though, extra variables just aren't showing up in the playbook job in AAP.



  • 5.  RE: vRA 8.7 - Ansible and Extra variables

    Posted Aug 02, 2022 12:07 AM

    Not sure if hostVars work that differently than extra-vars, but our ansible integration passes the password via the hostVars entry. We have it all encoded behind a pipe(|) delimiter so that it Ansible will read it all as a string, that it can parse. 

     

      Cloud_Ansible_1:
        type: Cloud.Ansible
        properties:
          # used to make the ansible integration optional via a checkbox.
          count: '${input.b_ansible == false ? 0 : 1}'
          host: ${resource.Cloud_Instance_1.*} 
          hostName: ${resource.Cloud_Instance_1.networks[0].address} # set hostname to IP machine's address
          osType: windows
          maxConnectionRetries: 20      
          account: 'production ansible'
          username: user # '${input.new_user_name}'
          password: userpass #'${input.a_user_password}'
          playbooks:
            provision:          
              - '${input.dev_script_path == ''OTHER'' ? input.otherAnsiblePath : input.default_script_path}'
            de-provision:
              - /home/playbooks/remove_domain_playbook.yml
          groups:
            - win
          hostVariables: |
            virtualEnvironment: AWS
            domain_oupath: ${input.domain_oupath == 'OTHER' ? input.otherOU : input.domain_oupath}
            domain: ${input.domain}
            hostname: ${input.hostname}
            accountId: ${env.projectName}
            ami_local_admin_password: ${input.admin_user_password}