Ansible inventory concerns

Hello :slight_smile:

I am deploying windows virtual machines with morpheus, on either azure or vmware. I’m trying to run post-installation script with ansible.
I have a unique playbook, importing several roles, each of them tighten with tags. I’ve created several tasks, one for each roles, and put them into a provisionning workflow.
Each task have “execute target” set to local.
When “launching” my provisioning workflow, it runs against the morpheus automated inventory, that is to say, it applies post installation on all my VMS !

My question is : how should i do to apply the post installation only ont the VM i am installing (something with --limit, perhaps, but i don’t know how to use it)

subsidiary question is that inventory is built with :slight_smile:
azr-dmlutst3.localdomain ansible_host=172.xx.xx.xx ansible_connection=winrm ansible_become_method=runas ansible_port=5985 ansible_winrm_transport=ntlm ansible_winrm_message_encryption=always ansible_user=AzureAdmin ansible_morpheus_container_id=178 ansible_ssh_common_args='-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'

but, i would like to connect with ssh, wether on windows or linux.

Could you give me some tips on these ?

If you do not need the Morpheus generated inventory, you can remove the Ansible integration from the group and cloud. That way Morpheus will have no inventory besides the context of the instance that you are running against.

I don’t believe there is any way to connect to windows using ssh with the Morpheus Ansible task type currently. Ansible security is much easier with the agent installed, if that’s possible.

I would love to use morpheus agent, but i don’t know how ; mainly because of the automated inventory which added ansible_connection=winrm.
How can i build a new, coorrect inventory, that connects through agent ?



I meant the Morpheus Agent Command Bus, which you can enable in the Ansible Integration. That’s the easiest way to use Ansible.

I would recommend deselecting your Ansible integration in the cloud configuration and the group configuration so that you aren’t using the Morpheus generated inventory. That way you will not have to worry about running on more than one instance when you don’t intend to.

and then, generate a dynamic inventory with add_host ? is there an example somewhere on github ?

When running an ansible task against an instance, that instance would be in the inventory you were running against. In Morpheus, that’s the context.

If you make sure you have nothing selected in the “Config Management” selection in both cloud and infrastructure groups, you can make a new repo to test with, and use something like this to show all the inventory members that were supplied to ansible:

- name: show inventory
  hosts: all
    - debug:
        var: groups