Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions course_scripts/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ cat <<EOF > userdata
#!/bin/bash
/usr/bin/aws s3 sync s3://${aws_s3_bucket.code.bucket} /var/www/html/
/bin/touch /var/spool/cron/root
sudo /usr/bin/yum install -y python27-boto3
sudo /bin/echo '*/5 * * * * aws s3 sync s3://${aws_s3_bucket.code.bucket} /var/www/html/' >> /var/spool/cron/root
EOF
EOT
Expand Down
30 changes: 22 additions & 8 deletions course_scripts/s3update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,26 @@
- hosts: dev
become: yes
remote_user: ec2-user

tasks:
- name: Update S3 code bucket
command: aws s3 sync /var/www/html/ s3://{{ s3code }}/ --delete
- shell: echo "define('WP_SITEURL','http://dev."{{ domain }}".com');" >> wp-config.php
args:
chdir: /var/www/html/
- shell: echo "define('WP_HOME','http://dev."{{ domain }}".com');" >> wp-config.php
args:
chdir: /var/www/html/
- name: Update S3 code bucket
s3_sync:
region: us-west-2
bucket: "{{ s3code }}"
delete: True
file_root: /var/www/html/

- name: Append WP_SITEURL to wp config
lineinfile:
regexp: "^define[(]'WP_SITEURL'"
line: "define('WP_SITEURL','http://dev.{{ domain }}.com');"
path: "/var/www/html/wp-config.php"
create: True
state: present

- name: Append WP_HOME to wp config
lineinfile:
regexp: "^define[(]'WP_HOME'"
line: "define('WP_HOME','http://dev.{{ domain }}.com');"
path: "/var/www/html/wp-config.php"
state: present
46 changes: 33 additions & 13 deletions course_scripts/wordpress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,43 @@
- hosts: dev
become: yes
remote_user: ec2-user

vars:
- apache_packages:
- httpd
- php
- php-mysql

tasks:
- name: Install Apache.
yum: name={{ item }} state=present
with_items:
- httpd
- php
- php-mysql
- name: Download WordPress
get_url: url=http://wordpress.org/wordpress-latest.tar.gz dest=/var/www/html/wordpress.tar.gz force=yes
- name: Extract WordPress
command: "tar xzf /var/www/html/wordpress.tar.gz -C /var/www/html --strip-components 1"
- name: Install apache
yum:
name: "{{ apache_packages }}"
state: present

- name: Download Wordpress
get_url:
url: http://wordpress.org/wordpress-latest.tar.gz
dest: /var/www/html/wordpress.tar.gz
force: yes

- name: Extract Wordpress
unarchive:
remote_src: True
src: /var/www/html/wordpress.tar.gz
dest: /var/www/html
extra_opts:
- "--strip-components=1"

- name: Make my directory tree readable
file:
path: /var/www/html/
mode: u=rwX,g=rX,o=rX
mode: "u=rwX,g=rX,o=rX"
recurse: yes
owner: apache
group: apache
- name: Make sure Apache is started now and at boot.
service: name=httpd state=started enabled=yes

- name: Make sure Apache is started now and at bood
service:
name: httpd
state: started
enabled: True