Skip to content

Instantly share code, notes, and snippets.

@b-long
Created February 10, 2017 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b-long/22d7d0216c84ac178e13702aac389002 to your computer and use it in GitHub Desktop.
Save b-long/22d7d0216c84ac178e13702aac389002 to your computer and use it in GitHub Desktop.
Experimental cloud-init file
#cloud-config
# Based on http://www.marcoberube.com/archives/272
# MiqProvisionAmazon_Web.yaml
# CloudForms - Cloud-Init Script for Apache Installation on EC2
# For troubleshooting check: /var/lib/cloud/instance/user-data.txt & /var/log/boot.log
<% # Set Global Variables
role = evm[:role]
role ||= evm[:ws_values][:role] rescue 'web'
instance_name = evm[:vm_target_name]
key_pair = evm[:keypair]
key_pair ||= evm[:ws_values][:keypair] rescue nil %>
bootcmd:
## Turn off SELinux
- setenforce 0
ssh_authorized_keys:
<% if key_pair.nil? %>
- echo "WARN --: Using default key pari"
<% else %>
- <%=key_pair%>
<% end %>
runcmd:
## Setup motd and root authorized keys
- echo Welcome to Red Hat CloudForms <%=role.titlecase%> Instance <%=instance_name%> > /etc/motd
## Turn off firewall
- echo "CloudForms - Turning off firewall"
- chkconfig iptables off
- service iptables stop
## Install Apache
- echo "CloudForms - Installing apache"
- yum -y install httpd wget
- service httpd start
- chkconfig httpd on
## Modify default apache homepage
- echo "CloudForms - Modifyig default apache homepage"
- echo 'Customized by b-long' > /var/www/html/index.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment