naoya0408 / menta

0 stars 0 forks source link

AWS (EC2+RDS)で構築したWordPressをterraform化する #33

Closed naoya0408 closed 4 years ago

naoya0408 commented 4 years ago

プルリクエストしますので、レビューをお願いいたします。

terraformの実行結果

% terraform init
% terraform apply
スクリーンショット 0001-11-03 18 29 48

ansibleの実行結果

% ansible-playbook -i aws_ec2.yml playbook.yml                                                                                                                           (git)-[feature]

PLAY [wordpress] ************************************************************************************************************************************************************************

TASK [Gathering Facts] ******************************************************************************************************************************************************************
ok: [web-server-1c]
ok: [web-server-1a]

TASK [nginx : enable amzn2extra-nginx1.12 repository] ***********************************************************************************************************************************
ok: [web-server-1c]
ok: [web-server-1a]

TASK [nginx : install nginx packages from amazon-linux-extras] **************************************************************************************************************************
ok: [web-server-1c]
ok: [web-server-1a]

TASK [nginx : start nginx] **************************************************************************************************************************************************************
changed: [web-server-1c]
changed: [web-server-1a]

TASK [nginx : copy nginx.conf] **********************************************************************************************************************************************************
ok: [web-server-1c]
ok: [web-server-1a]

TASK [php : amzn2-core.repo priority down] **********************************************************************************************************************************************
ok: [web-server-1c]
ok: [web-server-1a]

TASK [php : amzn2-extras.repo priority down] ********************************************************************************************************************************************
changed: [web-server-1c]
changed: [web-server-1a]

TASK [php : install epel/remi] **********************************************************************************************************************************************************
ok: [web-server-1a] => (item=http://rpms.famillecollet.com/enterprise/remi-release-7.rpm)
ok: [web-server-1c] => (item=http://rpms.famillecollet.com/enterprise/remi-release-7.rpm)
ok: [web-server-1c] => (item=https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm)
ok: [web-server-1a] => (item=https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm)

TASK [php : php72 install] **************************************************************************************************************************************************************
ok: [web-server-1c] => (item=php)
ok: [web-server-1a] => (item=php)
ok: [web-server-1c] => (item=php-devel)
ok: [web-server-1a] => (item=php-devel)
ok: [web-server-1c] => (item=php-fpm)
ok: [web-server-1a] => (item=php-fpm)
ok: [web-server-1c] => (item=php-gd)
ok: [web-server-1a] => (item=php-gd)
ok: [web-server-1c] => (item=php-mbstring)
ok: [web-server-1a] => (item=php-mbstring)
ok: [web-server-1c] => (item=php-mysqlnd)
ok: [web-server-1a] => (item=php-mysqlnd)

TASK [php : copy www.conf] **************************************************************************************************************************************************************
ok: [web-server-1c]
ok: [web-server-1a]

TASK [php : start php-fpm] **************************************************************************************************************************************************************
changed: [web-server-1a]
changed: [web-server-1c]

TASK [wordpress : download wordpress] ***************************************************************************************************************************************************
changed: [web-server-1a]
changed: [web-server-1c]

TASK [wordpress : create www directory] *************************************************************************************************************************************************
ok: [web-server-1c]
ok: [web-server-1a]

TASK [wordpress : unzip wordpress file] *************************************************************************************************************************************************
changed: [web-server-1c]
changed: [web-server-1a]

TASK [wordpress : permission change wordpress directory] ********************************************************************************************************************************
changed: [web-server-1c]
changed: [web-server-1a]

TASK [wordpress : restart nginx] ********************************************************************************************************************************************************
changed: [web-server-1c]
changed: [web-server-1a]

PLAY RECAP ******************************************************************************************************************************************************************************
web-server-1a              : ok=16   changed=7    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
web-server-1c              : ok=16   changed=7    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

;; ANSWER SECTION: aws-wordpress-alb-.ap-northeast-1.elb.amazonaws.com. 60 IN A 13.230.245.0 aws-wordpress-alb-.ap-northeast-1.elb.amazonaws.com. 60 IN A 13.115.25.219


アクセスが振り分けられていることがわかる
naoya0408 commented 4 years ago

変更点

ansibleの実行結果

% ansible-playbook -i hosts playbook.yml                                                                                                                                 (git)-[feature]

PLAY [all] ******************************************************************************************************************************************************************************

TASK [Gathering Facts] ******************************************************************************************************************************************************************
ok: [52.198.31.60]
ok: [3.112.222.233]

TASK [nginx : enable amzn2extra-nginx1.12 repository] ***********************************************************************************************************************************
ok: [52.198.31.60]
ok: [3.112.222.233]

TASK [nginx : install nginx packages from amazon-linux-extras] **************************************************************************************************************************
ok: [52.198.31.60]
ok: [3.112.222.233]

TASK [nginx : start nginx] **************************************************************************************************************************************************************
changed: [52.198.31.60]
changed: [3.112.222.233]

TASK [nginx : copy nginx.conf] **********************************************************************************************************************************************************
ok: [52.198.31.60]
ok: [3.112.222.233]

TASK [php : amzn2-core.repo priority down] **********************************************************************************************************************************************
ok: [52.198.31.60]
ok: [3.112.222.233]

TASK [php : amzn2-extras.repo priority down] ********************************************************************************************************************************************
changed: [52.198.31.60]
changed: [3.112.222.233]

TASK [php : install epel/remi] **********************************************************************************************************************************************************
changed: [52.198.31.60] => (item=http://rpms.famillecollet.com/enterprise/remi-release-7.rpm)
changed: [3.112.222.233] => (item=http://rpms.famillecollet.com/enterprise/remi-release-7.rpm)
ok: [52.198.31.60] => (item=https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm)
ok: [3.112.222.233] => (item=https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm)

TASK [php : php72 install] **************************************************************************************************************************************************************
changed: [52.198.31.60] => (item=php)
changed: [3.112.222.233] => (item=php)
changed: [52.198.31.60] => (item=php-devel)
changed: [3.112.222.233] => (item=php-devel)
changed: [52.198.31.60] => (item=php-fpm)
changed: [3.112.222.233] => (item=php-fpm)
changed: [52.198.31.60] => (item=php-gd)
changed: [3.112.222.233] => (item=php-gd)
changed: [52.198.31.60] => (item=php-mbstring)
changed: [3.112.222.233] => (item=php-mbstring)
changed: [52.198.31.60] => (item=php-mysqlnd)
changed: [3.112.222.233] => (item=php-mysqlnd)

TASK [php : start php-fpm] **************************************************************************************************************************************************************
changed: [3.112.222.233]
changed: [52.198.31.60]

TASK [php : copy www.conf] **************************************************************************************************************************************************************
changed: [52.198.31.60]
changed: [3.112.222.233]

TASK [wordpress : download wordpress] ***************************************************************************************************************************************************
changed: [52.198.31.60]
changed: [3.112.222.233]

TASK [wordpress : create www directory] *************************************************************************************************************************************************
ok: [3.112.222.233]
ok: [52.198.31.60]

TASK [wordpress : unzip wordpress file] *************************************************************************************************************************************************
changed: [3.112.222.233]
changed: [52.198.31.60]

TASK [wordpress : permission change wordpress directory] ********************************************************************************************************************************
changed: [3.112.222.233]
changed: [52.198.31.60]

TASK [wordpress : restart nginx] ********************************************************************************************************************************************************
changed: [52.198.31.60]
changed: [3.112.222.233]

RUNNING HANDLER [php : restart php-fpm] *************************************************************************************************************************************************
changed: [52.198.31.60]
changed: [3.112.222.233]

PLAY RECAP ******************************************************************************************************************************************************************************
3.112.222.233              : ok=17   changed=11   unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
52.198.31.60               : ok=17   changed=11   unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

ブラウザで初期設定を行い、ロードバランサーのDNS名にアクセス

スクリーンショット 0001-11-17 0 37 51
RVIRUS0817 commented 4 years ago

コード、テスト良いと思います!