Can we use ansible to provision an ec2 instance?

Can we use ansible playbook to provision ec instance and run some additional playbooks to make some configuration inside an ec instance at os level?

An Ansible playbook is capable of creating EC2 instances in AWS. You can also use Ansible to configure an OS once launched. I’m not sure you’d want to use Morpheus to run ad-hoc Ansible playbooks to launch unmanaged EC2 instances, though.

HI , Thanks for your response , We want to provision an ec2 instance + additional some configuration along with this ec2 task , While running ec2 playbook , it also has to run additional playbooks which does some additional configuration on storage side ,

But i stuck here to setp this workflow , Do you have any doc for ansible to provision ec on morphoues data , our playbooks are ready

There is no documentation on this because Morpheus uses it’s own internal process to provision EC2 instances. There is no supported workflow where Ansible is creating the instance.

Ok , Pls correct me ,

  1. we cannot use ansible playbook to provision an ec2 instance , we need to use different
    process to provision ec2 instance , is my understanding right ?

  2. But i want some different ansible playbooks to run along with ec2 instance provision task , is that can be done ?

Hi @Paul_B

The playbooks can be run before the start of provisioing the EC2 and more can be run after the instance is in the running state.

Can you elaborate more on the type of tasks you would execute in parallel to ec2 instance provisioning.

Hi Let me put my usecase ,

I want to keep couple of playbooks , one playbook(if morpheus data support) is to provision ec2 instance , then two more additional playbook to configure iscsi storage connectivity to onprem storage controller

OR
If we have to use morpheus data workflow to provision ec2 instance then after immediate we wanna run couple of playbooks , but that playbooks need to get the variable data from provisoned ec2 instance , data needs to be passed in to variable

More detailed explanation :

I want to provision a ec2 instance and get the value from cat /etc/iscsi/initiatorname.iscsi this file and pass this value to a playbook variable part ,

Condition : I can use ansible playbook to provision ec2 instance then run some different playbooks after ec3 provisioned .
Or if morphues data supports its own workflow to provision ec2 instance then we will be ready to use it but we want to get the value of cat /etc/iscsi/initiatorname.iscsi this file from the provisioned ec2 instance and pass this value to a playbook variable part which runs once ec2 provisoned

i want to if it can be done using morpheus data or not , working for one of the customer usecase

Provisioning an EC2 instance using Morpheus and running tasks against the machine once it is deployed is one of Morpheus’ primary use cases. You can run any supported task against a deployed instance.

Is there a way to get the variable from provisioned ec2 instance , pass it to the running tasks.

Example : A task is depending on provisioned instance ip address , ip address is dynamic , so a task need to fetch the ip from ec2 once it provisioned and pass it to the next task

If you’d like to see an example of the information that Morpheus makes available for it’s provisioning tasks, try this python task: morpheus-automation-examples/py-dump-env.py at main · gomorpheus/morpheus-automation-examples · GitHub You can put it in a provisioning workflow and run it against an instance.

I would recommend taking a look at some of the youtube videos we have available here: https://www.youtube.com/@Gomorpheus They can provide some understanding of the base level functions of Morpheus and how to use them.