fixed apache2 script, tested on centos7

This commit is contained in:
Anselm Levskaya
2015-12-10 06:19:32 -08:00
parent 37c02927d5
commit 822e2025ac
3 changed files with 26 additions and 58 deletions
+2 -2
View File
@@ -123,8 +123,8 @@ def make_instance(instance_name,
UserData=userdata,
InstanceType=machine_type)[0]
# brief pause to prevent rare EC2 error
time.sleep(0.5)
# brief pause to prevent rare error on EC2 delay, should block until ready instead
time.sleep(1.0)
# give instance a name
new_instance.create_tags(Tags=[{'Key': 'Name', 'Value': instance_name}])
+11 -17
View File
@@ -1,15 +1,7 @@
#!/bin/bash -x
#install apache2 on apt systems
# debian doesn't come with curl
#sudo apt-get update
#sudo apt-get -y --no-upgrade install apache2 #curl
# $PUBLIC_IP $PRIVATE_IP $PUBLIC_HOSTNAME $BOULDER_URL are dynamically set at execution
# fetch instance data from EC2 metadata service
#public_host=$(curl -s http://169.254.169.254/2014-11-05/meta-data/public-hostname)
#public_ip=$(curl -s http://169.254.169.254/2014-11-05/meta-data/public-ipv4)
#private_ip=$(curl -s http://169.254.169.254/2014-11-05/meta-data/local-ipv4)
# $OS_TYPE $PUBLIC_IP $PRIVATE_IP $PUBLIC_HOSTNAME $BOULDER_URL
# are dynamically set at execution
if [ $OS_TYPE = "ubuntu" ]
then
@@ -22,22 +14,24 @@ then
elif [ $OS_TYPE = "centos" ]
then
CONFFILE=/etc/httpd/conf/httpd.conf
sudo setenforce 0 || true #disable selinux
sudo yum -y install httpd
sudo service httpd start
sudo mkdir -p /var/www/$PUBLIC_HOSTNAME/public_html
sudo chmod -R 777 /var/www
sudo echo '<html><head><title>foo</title></head>\n<body>bar</body></html>' > /var/www/$PUBLIC_HOSTNAME/public_html/index.html
sudo mkdir /etc/httpd/sites-available
sudo mkdir /etc/httpd/sites-enabled
sudo echo "IncludeOptional sites-enabled/*.conf" >> /etc/httpd/conf/httpd.conf
sudo chmod -R oug+rwx /var/www
sudo chmod -R oug+rw /etc/httpd
sudo echo '<html><head><title>foo</title></head><body>bar</body></html>' > /var/www/$PUBLIC_HOSTNAME/public_html/index.html
sudo mkdir /etc/httpd/sites-available #letsencrypt requires this...
sudo mkdir /etc/httpd/sites-enabled #letsencrypt requires this...
#sudo echo "IncludeOptional sites-enabled/*.conf" >> /etc/httpd/conf/httpd.conf
sudo echo """
<VirtualHost *:80>
ServerName $PUBLIC_HOSTNAME
DocumentRoot /var/www/$PUBLIC_HOSTNAME/public_html
ErrorLog /var/www/$PUBLIC_HOSTNAME/error.log
CustomLog /var/www/$PUBLIC_HOSTNAME/requests.log combined
</VirtualHost>""" >> /etc/httpd/sites-available/$PUBLIC_HOSTNAME.conf
sudo cp /etc/httpd/sites-available/$PUBLIC_HOSTNAME.conf /etc/httpd/sites-enabled/
</VirtualHost>""" >> /etc/httpd/conf.d/$PUBLIC_HOSTNAME.conf
#sudo cp /etc/httpd/sites-available/$PUBLIC_HOSTNAME.conf /etc/httpd/sites-enabled/
fi
# run letsencrypt-apache2 via letsencrypt-auto
+13 -39
View File
@@ -33,28 +33,28 @@ targets:
type: ubuntu
virt: hvm
user: admin
userdata: |
#cloud-init
runcmd:
- [ apt-get, install, -y, curl ]
# userdata: |
# #cloud-init
# runcmd:
# - [ apt-get, install, -y, curl ]
- ami: ami-e0efab88
name: debian7.8.aws.1
type: ubuntu
virt: hvm
user: admin
userdata: |
#cloud-init
runcmd:
- [ apt-get, install, -y, curl ]
# userdata: |
# #cloud-init
# runcmd:
# - [ apt-get, install, -y, curl ]
- ami: ami-e6eeaa8e
name: debian7.8.aws.1_32bit
type: ubuntu
virt: pv
user: admin
userdata: |
cloud-init
runcmd:
- [ apt-get, install, -y, curl ]
# userdata: |
# #cloud-init
# runcmd:
# - [ apt-get, install, -y, curl ]
#-----------------------------------------------------------------------------
# Other Redhat Distros
- ami: ami-60b6c60a
@@ -62,41 +62,21 @@ targets:
type: centos
virt: hvm
user: ec2-user
userdata: |
#cloud-config
runcmd:
- yum -y install httpd
- service httpd start
- ami: ami-0d4cfd66
name: amazonlinux-2015.03.1
type: centos
virt: hvm
user: ec2-user
userdata: |
#cloud-config
runcmd:
- yum -y install httpd
- service httpd start
- ami: ami-a8d369c0
name: RHEL7
type: centos
virt: hvm
user: ec2-user
userdata: |
#cloud-config
runcmd:
- yum -y install httpd
- service httpd start
- ami: ami-518bfb3b
name: fedora23
type: centos
virt: hvm
user: fedora
userdata: |
#cloud-config
runcmd:
- yum -y install httpd
- service httpd start
#-----------------------------------------------------------------------------
# CentOS
# These Marketplace AMIs must, irritatingly, have their terms manually
@@ -106,11 +86,6 @@ targets:
type: centos
virt: hvm
user: centos
userdata: |
#cloud-config
runcmd:
- yum -y install httpd
- service httpd start
# centos6 requires EPEL repo added
- ami: ami-57cd8732
name: centos6
@@ -120,6 +95,5 @@ targets:
userdata: |
#cloud-config
runcmd:
- yum install -y epel-release httpd
- service httpd start
- yum install -y epel-release
- iptables -F