ansible / workshops

Training Course for Ansible Automation Platform
MIT License
1.75k stars 1.14k forks source link

manage_ec2_instances : save ami for ansible control node #361

Closed weslleyrosalem closed 4 years ago

weslleyrosalem commented 5 years ago
SUMMARY

Error in the last step before instance creation. It created the 3 nodes and ansible after hardcoded putting the attrbutes :

EXTRA VARS FILE
---
# region where the nodes will live
ec2_region: us-east-2
# name prefix for all the VMs
ec2_name_prefix: claroworkshop
# creates student_total of workbenches for the workshop
student_total: 2
# Set the right workshop type, like networking, rhel or f5 (see above)
workshop_type: rhel
#OPTIONAL VARIABLES
# password for Ansible control node, defaults to ansible
admin_password: ansible
# creates AWS S3 website for ec2_name_prefix.workshop_dns_zone
create_login_page: true                
# Sets the Route53 DNS zone to use for the S3 website
workshop_dns_zone: ocp-labs.com 
# automatically installs Tower to control node
towerinstall: true
# automatically licenses Tower if license is provided
autolicense: true
# install xrdp with xfce for graphical interface
#xrdp: true

for more information on the extra vars file please refer to: https://github.com/network-automation/linklight/blob/master/provisioner/README.md

ANSIBLE VERSION
ansible 2.8.3
CONFIGURATION
[root@ip-172-31-23-231 provisioner]# ansible-config dump --only-changed
DEFAULT_CALLBACK_WHITELIST(/root/workshops/provisioner/ansible.cfg) = ['time']
DEFAULT_FORKS(/root/workshops/provisioner/ansible.cfg) = 50
DEFAULT_HOST_LIST(/root/workshops/provisioner/ansible.cfg) = ['/root/workshops/provisioner/hosts']
DEFAULT_NO_TARGET_SYSLOG(/root/workshops/provisioner/ansible.cfg) = False
DEFAULT_SCP_IF_SSH(/root/workshops/provisioner/ansible.cfg) = True
DEFAULT_STDOUT_CALLBACK(/root/workshops/provisioner/ansible.cfg) = yaml
HOST_KEY_CHECKING(/root/workshops/provisioner/ansible.cfg) = False
INTERPRETER_PYTHON(/root/workshops/provisioner/ansible.cfg) = auto_silent
PERSISTENT_COMMAND_TIMEOUT(/root/workshops/provisioner/ansible.cfg) = 60
PERSISTENT_CONNECT_TIMEOUT(/root/workshops/provisioner/ansible.cfg) = 60
RETRY_FILES_ENABLED(/root/workshops/provisioner/ansible.cfg) = False
OS / ENVIRONMENT

RHEL

TOWER
PLAYBOOK SHORT OUTPUT
TASK [manage_ec2_instances : save ami for ansible control node] *******************************************************************************************************
fatal: [localhost]: FAILED! => 
  msg: |-
    The task includes an option with an undefined variable. The error was: No last item, sequence was empty.

    The error appears to be in '/home/wrosalem/linklight/provisioner/roles/manage_ec2_instances/tasks/provision.yml': line 25, column 3, but may
    be elsewhere in the file depending on the exact syntax problem.

    The offending line appears to be:

    - name: save ami for ansible control node
      ^ here
ptoal commented 5 years ago

The provisioner script now uses an AMI that is only available to Red Hat Customers with Cloud Access. (Refer to https://www.redhat.com/en/technologies/cloud-computing/cloud-access for instructions to register)

payalsin commented 5 years ago

Is there some other image that can be used. We are using a corporate AWS account with no control on subscription. Is there another AMI that can be used that is available to users by default

NetDevAutomate commented 5 years ago

I'm getting the same issue and do have the RHEL cloud images in the AWS account. Any ideas?

Error message:

TASK [manage_ec2_instances : save ami for ansible control node] **** Tuesday 15 October 2019 14:38:52 +0100 (0:00:01.805) 0:00:35.750 *** fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: No last item, sequence was empty.\n\nThe error appears to be in '/code/ansible/workshops/provisioner/roles/manage_ec2_instances/tasks/provision.yml': line 25, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: save ami for ansible control node\n ^ here\n"}

rcalvaga commented 5 years ago

Regarding RHEL AMIs, it's possible to do this change:

  filter: 'RHEL-7.6_HVM-20190618-x86_64-0-Hourly2-GP2'

Instead of 'RHEL-7.6_HVM-20190515-x86_64-0-Access2-GP2'

Just edit provisioner/roles/manage_ec2_instances/defaults/main.yml file.

rmarcandier13 commented 4 years ago

Regarding RHEL AMIs, it's possible to do this change:

  filter: 'RHEL-7.6_HVM-20190618-x86_64-0-Hourly2-GP2'

Instead of 'RHEL-7.6_HVM-20190515-x86_64-0-Access2-GP2'

Just edit provisioner/roles/manage_ec2_instances/defaults/main.yml file.

Thanks, it worked ;)

weslleyrosalem commented 4 years ago

Thanks @rcalvaga ;D

magicalyak commented 4 years ago

Can we have this be an option in the extra_vars.yml instead of having to modify the role vars? Ideally an hourly RHEL flag would be great that uses Hourly instead.

IPvSean commented 4 years ago

I feel like we need to change it something accessible for more folks, I need to talk to my counterpart RHEL TMM

jharmison-redhat commented 4 years ago

Would be good to get this to identify the base AMIs by pattern and have two options available for pattern.

VDI-Tech-Guy commented 4 years ago

Talked with @IPvSean about this, and recommended that a public instance of RHEL8 on AWS should be used rather than this specialized image as it would help the community deploy an instance without the need of registering for a special access image. Another thought is create a variable that could be modified that could use the Locked off image or the public AMI, but default to the public AMI

biggest issue with the current method is that there is limited documentation on how to access the image and its not in the main documents as a requirement.

magicalyak commented 4 years ago

@VDI-Tech-Guy that sounds great. Do you need a PR for this or is that already set?

VDI-Tech-Guy commented 4 years ago

@magicalyak - My understanding is Sean will look at it this week and let us know.

IPvSean commented 4 years ago

this is fixed and on standard image for RHEL8, sorry for the delay on the update here