{"id":427,"date":"2019-08-18T19:17:48","date_gmt":"2019-08-18T17:17:48","guid":{"rendered":"https:\/\/www.petersplanet.nl\/?p=427"},"modified":"2019-11-03T18:29:54","modified_gmt":"2019-11-03T16:29:54","slug":"create-a-wordpress-server-with-ansible-on-aws-1","status":"publish","type":"post","link":"https:\/\/www.petersplanet.nl\/index.php\/2019\/08\/18\/create-a-wordpress-server-with-ansible-on-aws-1\/","title":{"rendered":"Create a WordPress server with Ansible on AWS &#8211; Step 1"},"content":{"rendered":"\n<p>The idea is to fully script the creation of a WordPress server including the database on CentOS 8 and Amazon Web Services. For this Ansible will be used. I will describe this in several steps\/posts.<\/p>\n\n\n\n<p><strong>Step 1 Create the Linux server<\/strong><br> Step 1 is to create the Linux server from a bastion host within AWS. For now we will use CentOS 7 because CentOS 8 is not availabe. Later it will be changed for CentOS 8.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Update Ansible to the latest version<br> <code>yum -y update ansible<\/code><\/p>\n\n\n\n<p>Install boto3 because that is the SDK for AWS.<br><code>yum -y install python-pip<br>pip install --upgrade pip<br>pip install boto3<\/code><\/p>\n\n\n\n<p><code>$ ansible --version<br> ansible 2.8.2<\/code><\/p>\n\n\n\n<p>Set the AWS credentials via environment variables:<br> <code>export AWS_ACCESS_KEY_ID=\"XXXX\"<br> export AWS_SECRET_ACCESS_KEY=\"XXXX\"<\/code><\/p>\n\n\n\n<p>Create the script in a file create-centos7-aws.yml<\/p>\n\n\n\n<p>The CentOS AMI ID can be found for instance here: <a href=\"https:\/\/wiki.centos.org\/Cloud\/AWS\">https:\/\/wiki.centos.org\/Cloud\/AWS<\/a><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>\n# create-centos7-aws.yml\n#\n- hosts: localhost\n  connection: local\n  gather_facts: yes\n  tasks:\n  - name: Create CentOS instance on AWS\n    ec2_instance:\n      image_id: ami-6e28b517\n      instance_initiated_shutdown_behavior: stop\n      instance_type: t2.micro\n      key_name: xxxx-keypair-eu-ie\n      name: myinstance\n      region: eu-west-1\n      tags:\n        Environment: test\n      volumes:\n      - device_name: \/dev\/sda1\n        ebs:\n          volume_size: 8\n      vpc_subnet_id: subnet-xxxx\n      wait: yes\n      wait_timeout: 600<\/code><\/pre>\n\n\n\n<p>Run the script<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ansible-playbook create-centos7-aws.yml --become-user centos<\/code><\/pre>\n\n\n\n<p>This is all to create an instance on AWS. It takes some time for the script to be finished.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The idea is to fully script the creation of a WordPress server including the database on CentOS 8 and Amazon Web Services. For this Ansible will be used. I will describe this in several steps\/posts. Step 1 Create the Linux server Step 1 is to create the Linux server from a bastion host within AWS.<span class=\"excerpt-ellipsis\">&#8230;<\/span><\/p>\n<p><a class=\"more-link\" href=\"https:\/\/www.petersplanet.nl\/index.php\/2019\/08\/18\/create-a-wordpress-server-with-ansible-on-aws-1\/\" itemprop=\"url\">Continue Reading<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,5],"tags":[],"class_list":["post-427","post","type-post","status-publish","format-standard","hentry","category-cloud","category-linux"],"_links":{"self":[{"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/posts\/427","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/comments?post=427"}],"version-history":[{"count":23,"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/posts\/427\/revisions"}],"predecessor-version":[{"id":486,"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/posts\/427\/revisions\/486"}],"wp:attachment":[{"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/media?parent=427"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/categories?post=427"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/tags?post=427"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}