Skip to main content

AWS Security Specialty Exam Practice Test

Installing Ansible with CloudFormation and Userdata

AWS game-changing feature of supporting YAML in Cloudformation is a blessing for people who would love to see things in a "proper" format with comments :). Also it reduces the number of lines when compared to JSON.

Thanks to Graham for his basic tutorial on YAML and CloudFormation, borrowed much of his code and added ansible install. I haven't used cfn-init in the below snippet. Will try to enhance the code in future and make it more sophisticated.

Please note: I have hard-coded values of my key-pair etc, feel free to remove them. Please do leave a comment if you are running into any issues. I have used RHEL image for this tutorial.

AWSTemplateFormatVersion: "2010-09-09"

Description: A sample template

    Description: The path of the  file.
    Type: String
    Default: /home/ec2-user/userdata

    Type: "AWS::EC2::Instance" # 1 Quotes are unnecessary here - will they always be?
      ImageId: ami-26ebbc5c    # 2 Quotes removed from the example - still works
      InstanceType: t2.micro
      KeyName: gk-sairam
      Tags:                    # 3 Here I switch to using single spaces
       - Key: Role             # 4 Tag list item is inline
         Value: Test Instance
       -                       # 5 Next list item is block
         Key: Owner
         Value: GK
       -                       # 5 Next list item is block
         Key: name
         Value: gk-instance-1
      BlockDeviceMappings:     # 6 Switch back to double spaces
          DeviceName: /dev/sdm
            VolumeType: gp2
            VolumeSize: 10
        Fn::Base64: !Sub |     # No more Fn::Join needed
          echo "Testing Userdata" > ${FilePath}
          chown ec2-user.ec2-user ${FilePath}
          yum -y update
          yum -y install vim
          yum -y install net-tools
          yum -y install wget
          mkdir /tmp/ansible
          cd /tmp/ansible
          yum -y install epel-release-latest-7.noarch.rpm
          yum -y install ansible


  1. You there, this is really good post here. Thanks for taking the time to post such valuable information. Quality content is what always gets the visitors coming. CDN

  2. This blog is really helpful to deliver updated affairs over internet which is really appraisable. link name

  3. By default, files saved to the internal storage are private to your application and other applications cannot bomber women's black jacket access them (nor can the user). When the user uninstalls your application, these files are removed.

  4. There are a few things to keep in mind when using a roaming SIM card. First, it is important to check with your home network provider to see if they offer roaming services and what the charges will be. Second, you will need to make sure that your device is compatible with the roaming network that you will be using. Finally, you should be aware of the potential for high charges when using data services while roaming. SimCard for travel

  5. You have given essential data for us about Women's Black Amber Bracelet It is excellent and good for everyone. Keep posting. I am very thankful to you.


Post a Comment

Popular posts from this blog

AWS Security Specialty Exam Practice Test

Google Cloud VPC Basics for Associate Cloud Engineer - Part 1