VMware Aria Automation Tools

 View Only
  • 1.  vRA8 with Ansible - playbook selection

    Posted Aug 12, 2022 05:49 PM

    The following yaml works fine until I introduce the use of an input to select a playbook to execute. Without this everything works fine. The playbook itself is working fine as well. I have tried multiple iterations of the syntax and for the life of me always end up with the same error at deployment time. Can anyone confirm that in vRA8.9, the use of if/else yaml logic is supported within an Ansible block? I'm starting to think it isn't or if it was has regressed to an earlier 'error' state in this release.

    So to confirm, the problem statement is the following line:

    - '${input.ansible_role == "web" ? /etc/ansible/windows-iis-setup.yml : /etc/ansible/empty.yml}'

     

    Error is as follows:

    The only playbook run options supported are playbook level variables (Specified by -e OR --extra-vars). Please correct the following playbooks specified with unsupported options: ${input.ansible_role

     

    Full YAML as follows:

    formatVersion: 1
    inputs:
      ansible_role:
        type: string
        title: Ansible Role
        enum:
          - windows
          - web
    resources:
      Cloud_Ansible_1:
        type: Cloud.Ansible
        properties:
          host: ${resource.Cloud_vSphere_Machine_1.*}
          osType: windows
          account: aproans1003.automationpro.lan
          username: admin
          password: B4nananM@n!
          maxConnectionRetries: 30
          groups:
            - ${input.ansible_role}
          playbooks:
            provision:
              - /etc/ansible/common-windows-setup.yml
              - '${input.ansible_role == "web" ? /etc/ansible/windows-iis-setup.yml : /etc/ansible/empty.yml}'
      Cloud_vSphere_Machine_1:
        type: Cloud.vSphere.Machine
        properties:
          image: win2k22stdui
          cpuCount: 1
          totalMemoryMB: 8192
          storage:
            constraints:
              - tag: storage:cluster-gold
          networks:
            - network: ${resource.Cloud_vSphere_Network_1.id}
          tags:
            - key: ansible-role
              value: ${input.ansible_role}
      Cloud_vSphere_Network_1:
        type: Cloud.vSphere.Network
        properties:
          networkType: existing
          constraints:
            - tag: network.type:public



  • 2.  RE: vRA8 with Ansible - playbook selection
    Best Answer

    Posted Aug 12, 2022 06:16 PM

    I ran into the same issue.  What i did was pass some hostVariables to identify extra software and then added code in the main yml file to install IIS if the variable had a certain value.

    Design Blueprint YAML for hostVariables

     

    hostVariables: |
            vm_env: ${input.environment}
            servertype: ${input.servertype}
            sc: ${resource.WebApp_VM.sc}

     

     

     Ansible code (i use roles):

     

    - role: IIS
          when:
          - sc == "IIS"

     

     

    If you aren't familiar with roles, i suggest taking a look.  It significantly simplified my setup by putting all the logic for install in Ansible instead of trying to muddle through YAML logic.



  • 3.  RE: vRA8 with Ansible - playbook selection

    Posted Aug 13, 2022 08:18 PM

    Thanks, I had thought about this approach but was hoping to go down the original route. Out of curiosity, how do you deal with adding a host into multiple groups within ansible from vRA? The groups section seems to suffer with the same issue (ignoring expressions)!



  • 4.  RE: vRA8 with Ansible - playbook selection

    Posted Aug 14, 2022 07:17 PM

    I haven't tried dynamic groups with ansible yet.  I can tinker with it and see how it plays out.



  • 5.  RE: vRA8 with Ansible - playbook selection

    Posted Feb 24, 2025 07:51 PM

    Hi, I recently ran into this issue as well 
    https://community.broadcom.com/vmware-cloud-foundation/discussion/passing-aria-automation-818-project-properties-to-ansible-integration-stanza

    So if I move the hostVariables stanza to the main part of the yaml vs lower in the Ansible configuration section?