{"id":6129,"date":"2020-03-05T19:36:31","date_gmt":"2020-03-06T00:36:31","guid":{"rendered":"\/db-blog\/?p=6129"},"modified":"2020-03-12T01:39:06","modified_gmt":"2020-03-12T05:39:06","slug":"aws-terraform-ansible-openshift-provision-an-ec2-instance-and-further-configure-it-using-infrastructure-as-code","status":"publish","type":"post","link":"https:\/\/droidbasement.com\/db-blog\/aws-terraform-ansible-openshift-provision-an-ec2-instance-and-further-configure-it-using-infrastructure-as-code\/","title":{"rendered":"AWS\/Terraform\/Ansible\/OpenShift \u2013 Provision an EC2 instance and further configure it using Infrastructure as Code"},"content":{"rendered":"\n<p><em>Note: This is a duplicate of the <a rel=\"noreferrer noopener\" aria-label=\"AWS Lightsail (opens in a new tab)\" href=\"https:\/\/droidbasement.com\/db-blog\/aws-terraform-ansible-openshift-provision-a-lightsail-instance-and-perform-further-configurations-on-it-using-infrastructure-as-code\/\" target=\"_blank\">AWS Lightsail<\/a> article, modified for EC2 with some additional amendments.<\/em><\/p>\n\n\n\n<p>In this article we will Provision an EC2 host with docker\/docker-compose on it using Terraform and install\/initialize OpenShift Origin on it using Ansible.<\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\"OpenShift (opens in a new tab)\" href=\"https:\/\/www.openshift.com\/\" target=\"_blank\">OpenShift<\/a> is Red Hat&#8217;s containerization platform which utilizes Kubernetes.  <a href=\"https:\/\/www.okd.io\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"Origin (opens in a new tab)\">Origin<\/a> (what we will be working with here) is the opensource implementation of it.<\/p>\n\n\n\n<p>We will use &#8216;myweb&#8217; as an example in this article, using the same base path of &#8216;dev&#8217; that was <a rel=\"noreferrer noopener\" aria-label=\"previously created (opens in a new tab)\" href=\"https:\/\/droidbasement.com\/db-blog\/?p=5346\" target=\"_blank\">previously created<\/a>, the <a rel=\"noreferrer noopener\" aria-label=\"container-admin group (opens in a new tab)\" href=\"https:\/\/droidbasement.com\/db-blog\/?p=5501\" target=\"_blank\">container-admin group<\/a> and using ~\/.local\/bin for the binaries.<\/p>\n\n\n\n<p>Please ensure you have gone through the previous <a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/droidbasement.com\/db-blog\/aws-terraform-provision-an-ec2-instance-using-infrastructure-as-code\/\" target=\"_blank\">Terraform<\/a>, <a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/droidbasement.com\/db-blog\/aws-ansible-provision-an-ec2-instance-using-infrastructure-as-code\/\" target=\"_blank\">Ansible<\/a> and related preceding articles.<\/p>\n\n\n\n<p>Please use  <a rel=\"noreferrer noopener\" href=\"https:\/\/portal.aws.amazon.com\/billing\/signup?client=lightsail&amp;fid=1A3F6B376ECAC516-2C15C39C5ACECACB&amp;redirect_url=https%3A%2F%2Flightsail.aws.amazon.com%2Fls%2Fsignup#\/start\" target=\"_blank\">&#8216;<\/a><a rel=\"noreferrer noopener\" href=\"https:\/\/aws.amazon.com\/free\/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc\" target=\"_blank\">AWS Free Tier<\/a><a rel=\"noreferrer noopener\" href=\"https:\/\/portal.aws.amazon.com\/billing\/signup?client=lightsail&amp;fid=1A3F6B376ECAC516-2C15C39C5ACECACB&amp;redirect_url=https%3A%2F%2Flightsail.aws.amazon.com%2Fls%2Fsignup#\/start\" target=\"_blank\">&#8216;<\/a>  prior to commencing with this article. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>&#8211;&gt;<br>Go in to the dev directory\/link located within your home directory:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ cd ~\/dev<\/pre>\n\n\n\n<p>Update PIP:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ python3 -m pip install --upgrade --user pip<\/pre>\n\n\n\n<p>If there was an update, then forget remembered location references in the shell environment:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ hash -r pip <\/pre>\n\n\n\n<p>Upgrade the AWS CLI on your host:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ pip3 install awscli --upgrade --user &amp;&amp; chmod 754 ~\/.local\/bin\/aws<\/pre>\n\n\n\n<p>Install\/Upgrade Ansible:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ pip3 install ansible --upgrade --user &amp;&amp; chmod 754 ~\/.local\/bin\/ansible ~\/.local\/bin\/ansible-playbook<\/pre>\n\n\n\n<p>Install\/Upgrade Boto3:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ pip3 install boto3 --upgrade --user<\/pre>\n\n\n\n<p>Grab the latest version of Terraform:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ wget https:\/\/releases.hashicorp.com\/terraform\/0.12.23\/terraform_0.12.23_linux_amd64.zip<\/pre>\n\n\n\n<p>Unzip it to ~\/.local\/bin and set permissions accordingly on it (type y and hit enter to replace if upgrading, at the prompt):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ unzip terraform_0.12.23_linux_amd64.zip -d ~\/.local\/bin &amp;&amp; chmod 754 ~\/.local\/bin\/terraform<\/pre>\n\n\n\n<p>Change to the myweb directory inside terraform\/aws:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ cd terraform\/aws\/myweb<\/pre>\n\n\n\n<p>Change our instance from a micro to a medium, so it will have sufficient resources to run OpenShift Origin and related:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sed -i s:t3a.micro:t3a.medium: ec2.tf<\/pre>\n\n\n\n<p>Output the Public IP of the Provisioned host (along with connection parameters and variables) in to a file which we will feed in to an Ansible playbook run.<\/p>\n\n\n\n<p>Note: Please re-create the file if you have went through the previous Terraform articles:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ cat &lt;&lt; 'EOF' &gt; output.tf\n&gt; output \"static_public_ip\" {\n&gt;   value = var.lightsail ? element(aws_lightsail_static_ip.myweb[*].ip_address, 0) : element(aws_eip.external[*].public_ip, 0)\n&gt; }\n&gt;\n&gt; resource \"local_file\" \"hosts\" {\n&gt;   content              = trimspace(\"[vps]\\n${var.lightsail ? element(aws_lightsail_static_ip.myweb[*].ip_address, 0) : element(aws_eip.external[*].public_ip, 0)} ansible_connection=ssh ansible_user=ubuntu ansible_ssh_private_key_file=~\/.ssh\/${var.prefix} instance=${var.lightsail ? element(aws_lightsail_instance.myweb[*].name, 0) : element(aws_instance.myweb[*].tags[\"Name\"], 0)} ${var.lightsail ? \"\" : \"instance_sg=${element(aws_security_group.myweb[*].name, 0)}\"} ${var.lightsail ? \"\" : \"instance_sg_id=${element(aws_security_group.myweb[*].id, 0)}\"} ${var.lightsail ? \"\" : \"instance_vpc_id=${element(aws_vpc.myweb[*].id, 0)}\"}\")\n&gt;   filename             = pathexpand(\"~\/dev\/ansible\/hosts-aws\")\n&gt;   directory_permission = 0754\n&gt;   file_permission      = 0664\n&gt; }\n&gt; EOF<\/pre>\n\n\n\n<p>Amend an item from the user_data script (if you have went through the AWS\/Terraform\/Ansible\/OpenShift against Lightsail article then this can be disregarded):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sed -i 's:sudo apt-key add -:apt-key add -:' scripts\/install.sh<\/pre>\n\n\n\n<p>Initialize the directory\/refresh module(s):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ terraform init<\/pre>\n\n\n<p>Run a dry-run to see what will occur:<\/p>\n\n\n<pre class=\"wp-block-preformatted\">$ terraform plan -var 'lightsail=false'<\/pre>\n\n\n\n<p>Provision:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ terraform apply -var 'lightsail=false' -auto-approve<\/pre>\n\n\n\n<p>Create a work folder for an Ansible playbook:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ cd ..\/..\/..\/ansible\n$ mkdir -p openshift\/scripts &amp;&amp; cd openshift<\/pre>\n\n\n\n<p>Create an Ansible playbook which will install\/initialize OpenShift Origin on our provisioned host.<\/p>\n\n\n\n<p>Note: This accommodates our previous implementation against AWS Lightsail and Microsoft Azure VM:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ cat &lt;&lt; 'EOF' &gt; openshift.yml \n&gt; # Install, initialize OpenShift Origin and create a destroy routine for it\n&gt; # This is a unified setup against AWS Lightsail, Microsoft Azure VM and AWS EC2\n&gt; ---\n&gt; - hosts: vps\n&gt;   connection: local\n&gt;\n&gt;   vars:\n&gt;     network_security_group: \"{{ hostvars[groups['vps'][0]].instance_nsg }}\"\n&gt;     instance: \"{{ hostvars[groups['vps'][0]].instance }}\"\n&gt;     resource_group: \"{{ hostvars[groups['vps'][0]].instance_rg }}\"\n&gt;     security_group: \"{{ hostvars[groups['vps'][0]].instance_sg }}\"\n&gt;     security_group_id: \"{{ hostvars[groups['vps'][0]].instance_sg_id }}\"\n&gt;     virtual_private_cloud_id: \"{{ hostvars[groups['vps'][0]].instance_vpc_id }}\"\n&gt;     openshift_directory: \/home\/ubuntu\/.local\/etc\/openshift\n&gt;     ansible_python_interpreter: \/usr\/bin\/python3\n&gt;\n&gt;   tasks:\n&gt;     - name: Discover Services\n&gt;       service_facts:\n&gt;\n&gt;     - name: Check if openshift directory exists\n&gt;       stat:\n&gt;         path: \"{{ openshift_directory }}\"\n&gt;       register: openshift_dir\n&gt;       tags: [ 'destroy' ]\n&gt;\n&gt;     - name: Open Firewall Ports (AWS Lightsail)\n&gt;       delegate_to: localhost\n&gt;       args:\n&gt;         executable: \/bin\/bash\n&gt;       script: \".\/scripts\/firewall.sh open {{ instance }}\"\n&gt;       when:\n&gt;         - \"'instance_nsg' not in hostvars[groups['vps'][0]]\"\n&gt;         - \"'instance_sg' not in hostvars[groups['vps'][0]]\"\n&gt;         - \"'docker' in services\"\n&gt;         - openshift_dir.stat.exists == False\n&gt;\n&gt;     - name: Add Network Security Group rules (Microsoft Azure VM)\n&gt;       delegate_to: localhost\n&gt;       azure_rm_securitygroup:\n&gt;         name: \"{{ network_security_group }}\"\n&gt;         resource_group: \"{{ resource_group }}\"\n&gt;         rules:\n&gt;          - name: OpenShift-Tcp\n&gt;            priority: 1002\n&gt;            direction: Inbound\n&gt;            access: Allow\n&gt;            protocol: Tcp\n&gt;            source_port_range: \"*\"\n&gt;            destination_port_range:\n&gt;              - 80\n&gt;              - 443\n&gt;              - 1936\n&gt;              - 4001\n&gt;              - 7001\n&gt;              - 8443\n&gt;              - 10250-10259\n&gt;            source_address_prefix: \"*\"\n&gt;            destination_address_prefix: \"*\"\n&gt;          - name: OpenShift-Udp\n&gt;            priority: 1003\n&gt;            direction: Inbound\n&gt;            access: Allow\n&gt;            protocol: Udp\n&gt;            source_port_range: \"*\"\n&gt;            destination_port_range:\n&gt;              - 53\n&gt;              - 8053\n&gt;            source_address_prefix: \"*<em>\"<\/em>\n&gt;            destination_address_prefix: \"*\"\n&gt;        state: present\n&gt;      when:\n&gt;        - \"'instance_nsg' in hostvars[groups['vps'][0]]\"\n&gt;        - \"'instance_sg' not in hostvars[groups['vps'][0]]\"\n&gt;        - \"'docker' in services\"\n&gt;        - openshift_dir.stat.exists == False\n&gt;\n&gt;    - name: Add Security Group rules (AWS EC2)\n&gt;      delegate_to: localhost\n&gt;      ec2_group:\n&gt;        name: \"{{ security_group }}\"\n&gt;        description: OpenShift\n&gt;        vpc_id: \"{{ virtual_private_cloud_id }}\"\n&gt;        purge_rules: no\n&gt;        rules:\n&gt;         - proto: tcp\n&gt;           ports:\n&gt;             - 80\n&gt;             - 443\n&gt;             - 1936\n&gt;             - 4001\n&gt;             - 7001\n&gt;             - 8443\n&gt;             - 10250-10259\n&gt;           cidr_ip: 0.0.0.0\/0\n&gt;           rule_desc: OpenShift-Tcp\n&gt;         - proto: udp\n&gt;           ports:\n&gt;             - 53\n&gt;             - 8053\n&gt;           cidr_ip: 0.0.0.0\/0\n&gt;           rule_desc: OpenShift-Udp\n&gt;       state: present\n&gt;     when:\n&gt;       - \"'instance_nsg' not in hostvars[groups['vps'][0]]\"\n&gt;       - \"'instance_sg' in hostvars[groups['vps'][0]]\"\n&gt;       - \"'docker' in services\"\n&gt;       - openshift_dir.stat.exists == False\n&gt;\n&gt;   - name: Copy and Run install\n&gt;     environment:\n&gt;       PATH: \"{{ ansible_env.PATH}}:{{ openshift_directory }}\/..\/..\/bin\"\n&gt;     args:\n&gt;       executable: \/bin\/bash\n&gt;     script: \".\/scripts\/install.sh {{ ansible_ssh_host }}\"\n&gt;     when:\n&gt;       - \"'docker' in services\"\n&gt;       - openshift_dir.stat.exists == False\n&gt;\n&gt;   - debug: msg=\"Please install docker to proceed.\"\n&gt;     when: \"'docker' not in services\"\n&gt;\n&gt;   - debug: msg=\"Install script has already been completed.  Run this playbook with the destroy tag, then run once again normally to re-intialize openshift.\"\n&gt;     when: openshift_dir.stat.exists == True\n&gt;\n&gt;   - name: Destroy\n&gt;     become: yes\n&gt;     environment:\n&gt;       PATH: \"{{ ansible_env.PATH }}:{{ openshift_directory }}\/..\/..\/bin\"\n&gt;     args:\n&gt;       executable: \/bin\/bash\n&gt;     shell:\n&gt;       \"cd {{ openshift_directory }} &amp;&amp; oc cluster down &amp;&amp; cd ..\/ &amp;&amp; rm -rf {{ openshift_directory }}\/..\/..\/..\/.kube {{ openshift_directory }}\"\n&gt;     when: openshift_dir.stat.exists == True\n&gt;     tags: [ 'never', 'destroy' ]\n&gt;\n&gt;   - name: Close Firewall Ports (AWS Lightsail)\n&gt;     delegate_to: localhost\n&gt;     args:\n&gt;       executable: \/bin\/bash\n&gt;     script: \".\/scripts\/firewall.sh close {{ instance }}\"\n&gt;     when:\n&gt;       - \"'instance_nsg' not in hostvars[groups['vps'][0]]\"\n&gt;       - \"'instance_sg' not in hostvars[groups['vps'][0]]\"\n&gt;     tags: [ 'never', 'destroy' ]\n&gt;\n&gt;   - name: Delete Network Security Group rules (Microsoft Azure VM)\n&gt;     delegate_to: localhost\n&gt;     command:\n&gt;       bash -ic \"az-login-sp &amp;&amp; (az network nsg rule delete -g {{ resource_group }} --nsg-name {{ network_security_group }} -n {{ item }})\"\n&gt;     with_items:\n&gt;       - OpenShift-Tcp\n&gt;       - OpenShift-Udp\n&gt;     when:\n&gt;       - \"'instance_nsg' in hostvars[groups['vps'][0]]\"\n&gt;       - \"'instance_sg' not in hostvars[groups['vps'][0]]\"\n&gt;     tags: [ 'never', 'destroy' ]\n&gt;\n&gt;   - name: Delete Security Group rules (AWS EC2)\n&gt;     delegate_to: localhost\n&gt;     command:\n&gt;       bash -c \"[[ {{ item }} -eq 53 || {{ item }} -eq 8053 ]] &amp;&amp; protocol=udp || protocol=tcp &amp;&amp; aws ec2 revoke-security-group-ingress --group-id {{ security_group_id }} --port {{ item }} --protocol $protocol --cidr 0.0.0.0\/0\"\n&gt;     with_items:\n&gt;       - 80\n&gt;       - 443\n&gt;       - 1936\n&gt;       - 4001\n&gt;       - 7001\n&gt;       - 8443\n&gt;       - 10250-10259\n&gt;       - 53\n&gt;       - 8053\n&gt;     when:\n&gt;       - \"'instance_nsg' not in hostvars[groups['vps'][0]]\"\n&gt;       - \"'instance_sg' in hostvars[groups['vps'][0]]\"\n&gt;     tags: [ 'never', 'destroy' ]\n&gt; EOF<\/pre>\n\n\n\n<p>Create a shell script which will pull the latest release of client tools from GitHub, place the needed binaries in ~\/.local\/bin, set insecure registry on Docker and initialize (if you have went through the AWS\/Terraform\/Ansible\/OpenShift against Lightsail article then this can be disregarded):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ cat &lt;&lt; 'EOF' &gt; scripts\/install.sh\n&gt; #!\/bin\/bash\n&gt; [[ -z $* ]] &amp;&amp; { echo \"Please specify a Public IP or Host\/Domain name.\" &amp;&amp; exit 1; }\n&gt; # Fetch and Install\n&gt; file_url=\"$(curl -sL https:\/\/github.com\/openshift\/origin\/releases\/latest | grep \"download.*client.*linux-64\" | cut -f2 -d\\\" | sed 's\/^\/https:\\\/\\\/github.com\/')\"\n&gt; [[ -z $file_url ]] &amp;&amp; { echo \"The URL could not be obtained.  Please try again shortly.\" &amp;&amp; exit 1; }\n&gt; file_name=\"$(echo $file_url | cut -f9 -d\/)\"\n&gt; if [[ ! -f $file_name ]]; then\n&gt;         curl -sL $file_url --output $file_name\n&gt;         folder_name=\"$(tar ztf $file_name 2&gt;\/dev\/null | head -1 | sed s:\/.*::)\"\n&gt;         [[ -z $folder_name ]] &amp;&amp; { echo \"The archive could not be read.  Please try again.\" &amp;&amp; rm -f $file_name &amp;&amp; exit 1; }\n&gt;         tar zxf $file_name\n&gt;         mv $folder_name\/oc $folder_name\/kubectl $HOME\/.local\/bin &amp;&amp; rm -r $folder_name\n&gt;         chmod 754 $HOME\/.local\/bin\/oc $HOME\/.local\/bin\/kubectl\n&gt; fi\n&gt; # Docker insecure\n&gt; [[ $(grep insecure \/etc\/docker\/daemon.json &amp;&gt;\/dev\/null; echo $?) -eq 2 ]] &amp;&amp; redirect=\"&gt;\"\n&gt; [[ $(grep insecure \/etc\/docker\/daemon.json &amp;&gt;\/dev\/null; echo $?) -eq 1 ]] &amp;&amp; redirect=\"&gt;&gt;\"\n&gt; [[ $(grep insecure \/etc\/docker\/daemon.json &amp;&gt;\/dev\/null; echo $?) -eq 0 ]] || { sudo bash -c \"cat &lt;&lt; 'EOF' $redirect \/etc\/docker\/daemon.json\n&gt; {\n&gt;         \\\"insecure-registries\\\" : [ \\\"172.30.0.0\/16\\\" ]\n&gt; }\n&gt; EOF\" &amp;&amp; sudo systemctl restart docker; }\n&gt; # OpenShift Origin up\n&gt; [[ ! -d $HOME\/.local\/etc\/openshift ]] &amp;&amp; { mkdir -p $HOME\/.local\/etc\/openshift &amp;&amp; cd $HOME\/.local\/etc\/openshift; } || { cd $HOME\/.local\/etc\/openshift &amp;&amp; oc cluster down; }\n&gt; oc cluster up --public-hostname=$1\n&gt;\n&gt; exit 0\n&gt; EOF <\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>Note:  If you have already went through the AWS\/Terraform\/Ansible\/OpenShift for Lightsail article or you don&#8217;t want to use Lightsail, then this can be disregarded.<\/p>\n\n\n\n<p>The Lightsail firewall functionality is currently being implemented in Terraform and is not available in Ansible.  In the interim, we will create a shell script to open and close ports needed by OpenShift Origin (using the AWS CLI).  This script will be run locally via the Playbook during the create and destroy routines.<\/p>\n\n\n\n<p>Note2:  Port 80 is already open when the Lightsail host is provisioned: <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ cat &lt;&lt; 'EOF' &gt; scripts\/firewall.sh &amp;&amp; chmod 754 scripts\/firewall.sh\n&gt; #!\/bin\/bash\n&gt; #\n&gt; openshift_ports=\"53\/UDP 443\/TCP 1936\/TCP 4001\/TCP 7001\/TCP 8053\/UDP 8443\/TCP 10250_10259\/TCP\"  \n&gt; #\n&gt; [[ -z $* || $(echo $* | xargs -n1 | wc -l) -ne 2 || ! ($* =~ $(echo '\\&lt;open\\&gt;') || $* =~ $(echo '\\&lt;close\\&gt;')) ]] &amp;&amp; { echo \"Please pass in the desired action [ open, close ] and instance [ site_myweb ].\" &amp;&amp; exit 2; }\n&gt; #\n&gt; instance=\"$(echo $* | xargs -n1 | sed '\/\\&lt;open\\&gt;\/d; \/\\&lt;close\\&gt;\/d')\"\n&gt; [[ -z $instance ]] &amp;&amp; { echo \"Please double-check the passed in instance.\" &amp;&amp; exit 1; }\n&gt; action=\"$(echo $* | xargs -n1 | grep -v $instance)\"\n&gt; #\n&gt; for port in $openshift_ports; do\n&gt;         aws lightsail $action-instance-public-ports --instance $instance --port-info fromPort=$(echo $port | cut -f1 -d_ | cut -f1  -d\/),protocol=$(echo $port | cut -f2 -d\/),toPort=$(echo $port | cut -f2 -d_ | cut -f1 -d\/)\n&gt; done\n&gt; #\n&gt;\n&gt; exit 0\n&gt; EOF <\/pre>\n\n\n\n<p>Run the Ansible playbook after a few minutes (accept the host key by typing yes and hitting enter when prompted):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ ansible-playbook -i ..\/hosts-aws openshift.yml<\/pre>\n\n\n\n<p>Note: Disregard the warning regarding mismatch descriptions on the Security Group.  This will not be modified so the original description was not exported out to be used here.<\/p>\n\n\n\n<p>Note2: If a Terraform apply is run again after the security group modification (addition of rules for OpenShift), then those rules will be destroyed.  In that case, please run a Playbook destroy then run again to reinitialize.<\/p>\n\n\n\n<p>After a short while, log on to the instance:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ ssh -i ~\/.ssh\/myweb ubuntu@&lt;The value of static_public_ip that was reported.  One can also use 'terraform output static_public_ip' to print it again.&gt;<\/pre>\n\n\n\n<p>To get an overview of the current project with any identified issues:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ oc status --suggest<\/pre>\n\n\n\n<p>Log on as Admin via CMD Line and switch to the default project:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ oc login -u system:admin -n default<\/pre>\n\n\n\n<p>Logout of the session:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ oc logout<\/pre>\n\n\n\n<p>Please see the <a rel=\"noreferrer noopener\" aria-label=\"Command-Line Walkthrough (opens in a new tab)\" href=\"https:\/\/docs.openshift.com\/enterprise\/3.2\/getting_started\/developers_cli.html\" target=\"_blank\">Command-Line Walkthrough<\/a>.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Logout from the host:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ logout<\/pre>\n\n\n\n<p>Log on as Admin via Web Browser (replace &lt;PUBLIC_IP&gt;):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">https:\/\/&lt;PUBLIC_IP&gt;:8443\/console (You will get a Certificate\/Site warning due to a mismatch).<\/pre>\n\n\n\n<p>Please see the <a href=\"https:\/\/docs.openshift.com\/enterprise\/3.2\/getting_started\/developers_console.html\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"Web Console Walkthrough (opens in a new tab)\">Web Console Walkthrough<\/a>.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>To shut down the OpenShift Origin cluster, destroy the working folder and start anew (you can re-run the playbook normally to reinitialize):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ ansible-playbook -i ..\/hosts openshift.yml --tags \"destroy\"<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>Tear down what was created by first performing a dry-run to see what will occur:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ cd ..\/..\/terraform\/aws\/myweb &amp;&amp; terraform plan -var 'lightsail=false' -destroy <\/pre>\n\n\n\n<p>Tear down the instance:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ terraform destroy -var 'lightsail=false' -auto-approve<\/pre>\n\n\n\n<p>&lt;&#8211;<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>References:<br><a href=\"https:\/\/www.techrepublic.com\/article\/how-to-install-openshift-origin-on-ubuntu-18-04\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"how-to-install-openshift-origin-on-ubuntu-18-04 (opens in a new tab)\">how-to-install-openshift-origin-on-ubuntu-18-04<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Source: <br><a href=\"https:\/\/github.com\/pershoot\/ansible_openshift\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"ansible_openshift (opens in a new tab)\">ansible_openshift<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Note: This is a duplicate of the AWS Lightsail article, modified for EC2 with some additional amendments. In this article we will Provision an EC2 host with docker\/docker-compose on it using Terraform and install\/initialize OpenShift Origin on it using Ansible. OpenShift is Red Hat&#8217;s containerization platform which utilizes Kubernetes. Origin (what we will be working [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-6129","post","type-post","status-publish","format-standard","hentry","category-devops"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/droidbasement.com\/db-blog\/wp-json\/wp\/v2\/posts\/6129","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/droidbasement.com\/db-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/droidbasement.com\/db-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/droidbasement.com\/db-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/droidbasement.com\/db-blog\/wp-json\/wp\/v2\/comments?post=6129"}],"version-history":[{"count":54,"href":"https:\/\/droidbasement.com\/db-blog\/wp-json\/wp\/v2\/posts\/6129\/revisions"}],"predecessor-version":[{"id":6242,"href":"https:\/\/droidbasement.com\/db-blog\/wp-json\/wp\/v2\/posts\/6129\/revisions\/6242"}],"wp:attachment":[{"href":"https:\/\/droidbasement.com\/db-blog\/wp-json\/wp\/v2\/media?parent=6129"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/droidbasement.com\/db-blog\/wp-json\/wp\/v2\/categories?post=6129"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/droidbasement.com\/db-blog\/wp-json\/wp\/v2\/tags?post=6129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}