Posts

ARTH TASK 23 [📌 Automate Kubernetes Cluster Using Ansible 🔅 Launch ec2-instances on AWS Cloud eg. for master and slave. 🔅 Create roles that will configure master node and slave node seperately. 🔅 Launch a wordpress and mysql database connected to it in the respectine slaves. 🔅 Expose the wordpress pod and client able hit the wordpress ip with its respective port. ]

Image
  Installing Python3:   $ yum install python3 -y Installing the boto3 library:  $ pip3 install boto Creating a inventory directory: $ mkdir -p /opt/ansible/inventory $ cd /opt/ansible/inventory Creating a file aws_ec2.yaml in the inventory directory with the following configuration: plugin: aws_ec2 aws_access_key: <YOUR-AWS-ACCESS-KEY-HERE> aws_secret_key: <YOUR-AWS-SECRET-KEY-HERE> keyed_groups: - key: tags prefix: tag Open /etc/ansible/ansible.cfg and find the [inventory] section and add the following line to enable the ec2 plugin: [inventory] enable_plugins = aws_ec2 Now let’s test the dynamic inventory configuration by listing the EC2 instances: $ ansible-inventory -i /opt/ansible/inventory/aws_ec2.yaml --list The above command returns the list of EC2 instances with all its parameters in JSON format. Now, check if Ansible is able to ping all the machines returned by the dynamic inventory:  ansible all -m ping Dynamic inventory setup done. Launch...

ARTH TASK 19 [📌 Ansible Role to Configure K8S Multi Node Cluster over AWS Cloud. 🔅 Create Ansible Playbook to launch 3 AWS EC2 Instance 🔅 Create Ansible Playbook to configure Docker over those instances. 🔅 Create Playbook to configure K8S Master, K8S Worker Nodes on the above created EC2 Instances using kubeadm. 🔅 Convert Playbook into roles and Upload those role on your Ansible Galaxy. 🔅 Also Upload all the YAML code over your GitHub Repository. 🔅 Create a README.md document using markdown language describing your Task in creative manner. 🔅 Create blog about task and share on your LinkedIN profile.]

Image
  Step 1 : Setup the Ansible configuration file and the inventory. My setup is built upon a dynamic inventory. For details visit:  Automating HAProxy using Ansible. Using ansible for configuring HAProxy… | by Gursimar Singh | Mar, 2021 | Medium Configuration File ansible.cfg : To setup dynamic inventory for AWS EC2 instances, download  ec2.py  and  ec2.ini  file to the controller node using the  wget  command. $ wget https://raw.githubusercontent.com/ansible/ansible/stable-2.9/contrib/inventory/ec2.py $ wget https://raw.githubusercontent.com/ansible/ansible/stable-2.9/contrib/inventory/ec2.ini Install the SDK for AWS that is boto3 $ pip3 install boto3 Make these 2 files executable: $ chmod +x ec2.py $ chmod +x ec2.ini Export the following variables along with their values for our particular AWS account, in my case I have chosen region as ap-south-1. Step 2 : Create 3 roles using the ansible-galaxy init command namely, aws_ec2 :- To setup 3 AWS EC2...