This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.

⚠️ We've moved!

Hi there!

To reduce project dependency on 3rd party paid services the StackStorm TSC has decided to move the Q/A from this forum to Github Discussions. This will make user experience better integrated with the native Github flow, as well as the questions closer to the community where they can provide answers.

Use 🔗 Github Discussions to ask your questions.

How to create an ec2 instance with ansible playbook

Hi,
I am trying to create an EC2 instance using ansible Package.
When ansible playbook is executed, it is output as follows

Action Output

{
  "succeeded": false,
  "failed": true,
  "return_code": 2,
  "stderr": "[WARNING]: No inventory was parsed, only implicit localhost is available\n[WARNING]: provided hosts list is empty, only localhost is available. Note that\nthe implicit localhost does not match 'all'\nExecuted command \"/opt/stackstorm/virtualenvs/ansible/bin/ansible-playbook /ansible_playbooks/ec2a/roles/lamp.yml\"",
  "stdout": "\nPLAY [localhost] ***************************************************************\n\nTASK [Gathering Facts] *********************************************************\nok: [localhost]\n\nTASK [aws : create keypair] ****************************************************\nfatal: [localhost]: FAILED! => {\"changed\": false, \"msg\": \"Failed to import the required Python library (botocore or boto3) on stack's Python /opt/stackstorm/virtualenvs/ansible/bin/python. Please read module documentation and install in the appropriate location\"}\n\nPLAY RECAP *********************************************************************\nlocalhost                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   \n"
}

error

{
  "succeeded": false,
  "failed": true,
  "return_code": 2,
  "stderr": "[WARNING]: No inventory was parsed, only implicit localhost is available\n[WARNING]: provided hosts list is empty, only localhost is available. Note that\nthe implicit localhost does not match 'all'\nExecuted command \"/opt/stackstorm/virtualenvs/ansible/bin/ansible-playbook /ansible_playbooks/ec2a/roles/lamp.yml\"",
  "stdout": "\nPLAY [localhost] ***************************************************************\n\nTASK [Gathering Facts] *********************************************************\nok: [localhost]\n\nTASK [aws : create keypair] ****************************************************\nfatal: [localhost]: FAILED! => {\"changed\": false, \"msg\": \"Failed to import the required Python library (botocore or boto3) on stack's Python /opt/stackstorm/virtualenvs/ansible/bin/python. Please read module documentation and install in the appropriate location\"}\n\nPLAY RECAP *********************************************************************\nlocalhost                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   \n"
}

There seems to be no boto3, but how can I solve it?

You can run the following command to install boto3 library into ansible pack virtual environment:

/opt/stackstorm/virtualenvs/ansible/bin/pip install boto3

Hi, Tomaz
Thank you for answering.
I executed the command I was told, but the following error occurred.

"traceback": "Traceback (most recent call last):
  File \"/opt/stackstorm/st2/lib/python2.7/site-packages/action_chain_runner/action_chain_runner.py\", line 496, in _run_chain
    action_params=action_parameters, context_result=context_result)
  File \"/opt/stackstorm/st2/lib/python2.7/site-packages/action_chain_runner/action_chain_runner.py\", line 731, in _get_next_action
    chain_context={'parent': parent_context})
  File \"/opt/stackstorm/st2/lib/python2.7/site-packages/action_chain_runner/action_chain_runner.py\", line 713, in _resolve_params
    raise action_exc.ParameterRenderingFailedException(msg)
ParameterRenderingFailedException: Failed rendering value for action parameter \"ImageId\" in task \"run_instance\" (template string={{Image_id}}): 'Image_id' is undefined
"

How can it be solved?