current nonworking progress at scripting install of httpd on centos-like systems

This commit is contained in:
Anselm Levskaya 2015-12-09 16:52:02 -08:00
parent 50232f3fec
commit 37c02927d5
5 changed files with 106 additions and 52 deletions

View file

@ -29,8 +29,9 @@ then:
```
see:
https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html
https://docs.aws.amazon.com/cli/latest/userguide/cli-ec2-keypairs.html
- https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html
- https://docs.aws.amazon.com/cli/latest/userguide/cli-ec2-keypairs.html
https://github.com/letsencrypt/boulder
https://github.com/letsencrypt/letsencrypt
main repos:
- https://github.com/letsencrypt/boulder
- https://github.com/letsencrypt/letsencrypt

View file

@ -271,12 +271,13 @@ def config_and_launch_boulder(instance):
execute(deploy_script, 'scripts/boulder_config.sh')
execute(run_boulder)
def install_and_launch_letsencrypt(instance, boulder_url):
def install_and_launch_letsencrypt(instance, boulder_url, target):
execute(local_repo_to_remote)
with shell_env(BOULDER_URL=boulder_url,
PUBLIC_IP=instance.public_ip_address,
PRIVATE_IP=instance.private_ip_address,
PUBLIC_HOSTNAME=instance.public_dns_name):
PUBLIC_HOSTNAME=instance.public_dns_name,
OS_TYPE=target['type']):
execute(deploy_script, cl_args.test_script)
def grab_letsencrypt_log():
@ -423,7 +424,7 @@ def test_client_process(inqueue, outqueue):
print(env.host_string)
try:
install_and_launch_letsencrypt(instances[ii], boulder_url)
install_and_launch_letsencrypt(instances[ii], boulder_url, target)
outqueue.put((ii, target, 'pass'))
print("%s - %s SUCCESS"%(target['ami'], target['name']))
except:

50
scripts/test_apache2.sh Executable file
View file

@ -0,0 +1,50 @@
#!/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)
if [ $OS_TYPE = "ubuntu" ]
then
CONFFILE=/etc/apache2/sites-available/000-default.conf
sudo apt-get update
sudo apt-get -y --no-upgrade install apache2 #curl
# For apache 2.4, set up ServerName
sudo sed -i '/ServerName/ s/#ServerName/ServerName/' $CONFFILE
sudo sed -i '/ServerName/ s/www.example.com/'$PUBLIC_HOSTNAME'/' $CONFFILE
elif [ $OS_TYPE = "centos" ]
then
CONFFILE=/etc/httpd/conf/httpd.conf
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 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/
fi
# run letsencrypt-apache2 via letsencrypt-auto
cd letsencrypt
./bootstrap/install-deps.sh
./bootstrap/dev/venv.sh
source ./venv/bin/activate
sudo ./venv/bin/letsencrypt -v --debug --text --agree-dev-preview --agree-tos \
--renew-by-default --redirect --register-unsafely-without-email \
--domain $PUBLIC_HOSTNAME --server $BOULDER_URL

View file

@ -1,24 +0,0 @@
#!/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)
# For apache 2.4, set up ServerName
sudo sed -i '/ServerName/ s/#ServerName/ServerName/' \
/etc/apache2/sites-available/000-default.conf
sudo sed -i '/ServerName/ s/www.example.com/'$PUBLIC_HOSTNAME'/' \
/etc/apache2/sites-available/000-default.conf
# run letsencrypt-apache2 via letsencrypt-auto
cd letsencrypt
./letsencrypt-auto -v --debug --text --agree-dev-preview --agree-tos \
--renew-by-default --redirect --register-unsafely-without-email \
--domain $PUBLIC_HOSTNAME --server $BOULDER_URL

View file

@ -30,7 +30,7 @@ targets:
# Debian
- ami: ami-116d857a
name: debian8.1
type: debian
type: ubuntu
virt: hvm
user: admin
userdata: |
@ -39,7 +39,7 @@ targets:
- [ apt-get, install, -y, curl ]
- ami: ami-e0efab88
name: debian7.8.aws.1
type: debian
type: ubuntu
virt: hvm
user: admin
userdata: |
@ -48,7 +48,7 @@ targets:
- [ apt-get, install, -y, curl ]
- ami: ami-e6eeaa8e
name: debian7.8.aws.1_32bit
type: debian
type: ubuntu
virt: pv
user: admin
userdata: |
@ -62,38 +62,64 @@ 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: redhat
type: centos
virt: hvm
user: ec2-user
userdata: |
#cloud-config
runcmd:
- yum -y install httpd
- service httpd start
- ami: ami-518bfb3b
name: fedora23
type: fedora
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
# agreed to on the AWS marketplace site for any new AWS account using them...
# - ami: ami-61bbf104
# name: centos7
# type: centos
# virt: hvm
# user: centos
# # centos6 requires EPEL repo added
# - ami: ami-57cd8732
# name: centos6
# type: centos
# virt: hvm
# user: centos
# userdata: |
# #cloud-config
# runcmd:
# - [ yum, install, -y, epel-release ]
# - [ iptables, -F ]
- ami: ami-61bbf104
name: centos7
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
type: centos
virt: hvm
user: centos
userdata: |
#cloud-config
runcmd:
- yum install -y epel-release httpd
- service httpd start
- iptables -F