Homework labs for the course DevOps prctice at OTUS
- Create YC infra and set up SSH access via the Bastion host.
- Set up VPN service Pritunl
- Set SSL certificate with Let's Encrypt for Pritunl server.
- Update the README.md with Lab info.
- Autotest with the Github Actions and delete YC instances if ok.
bastion_IP = 84.252.129.223
someinternalhost_IP = 10.128.0.34
HW of Lab_005
Create YC infra and set up SSH access via the Bastion host.
Two Compute Clouds was created:
bastion host with public ip - 84.252.129.223 comeinternalhost with only lockal address
Locally generated ssh key-pair was inserted to this hosts (public key)
~/.ssh/config has been created to connect easily in a short format like ssh somehost:
Host bastion
HostName 84.252.129.223
User appuser
IdentityFile ~/.ssh/appuser
ForwardAgent yes
Host inthost
HostName 10.128.0.34
User appuser
IdentityFile ~/.ssh/appuser
ForwardAgent yes
ProxyJump bastion
So, to connect to someinternalhost via bastion just type:
ssh inthostYou can also reach it with the command:
ssh -i ~/.ssh/appuser -A -J appuser@84.252.129.223 appuser@10.128.0.34Set up the VPN service Pritunl
A Pritunl server was deployed on the Bastion host with the setupvpn.sh
To connect to internal hosts via VPN use the cloud-bastion.ovpn. To insert the config to your openvpn client:
wget https://bit.ly/3mnEQfk -O cloud-bastion.ovpn
openvpn3 config-import --config cloud-bastion.ovpnThen start the VPN tunnel session
openvpn3 session-start --config cloud-bastion.ovpn(3) Set SSL certificate. To enable the Let's Encrypt bot just set the domain name 84.252.129.223.sslip.io to the settings at Lets Encrypt Domain field on Pritunl web interface on Bastion host.
(4) README.md updated
- Setup YC console.
- Create a host by YC CLI.
- Install Ruby and MongoDB.
- Deploy an App and check the functionality.
- Create the Bash-scripts to that steps automatically.
- Create a metadata.yaml
- Create an infra and deploy the app with one command at YC CLI.
Steps 1-4 has done.
(5) Scripts:
(6) Metadata.yaml describes the environment the App will be run in.
(7) Check the app with link
testapp_IP = 178.154.209.113
testapp_port = 9292
- Configure Packer account in YC CLI.
- Create a Packer template.
- Create an image in YC with Packer template and deploy an app.
- Configure parameters and hide secrets from git.
- * Create a bake image to deploy an app with one command.
- Packer template ubuntu16.json
- Packer variables.json added to .gitignore to hide secrets.
- Scripts to make the image and deploy apps:
- A baked image created with immutable.json
To start a VM with the Puma app deployed run the create-reddit-vm.sh script with parameter file create-reddit-vm.yaml (should be placed to the same folder as the script is).
The script will create a VM based on previously created reddit-full image with all necessary components installed in it.
To check the result go to http://VM-ip:9292 the Monolith reddit app will appear.
- Create Terraform config files.
- Create a VM in YC with Terraform template and deploy an app.
- Configure parameters and hide secrets from git.
- * Configure a Load Balancer to deploy an app with two instances and check the app availability.
To check the result go to http://VM-ip:9292 the Monolith reddit app will appear.
- Divide App and DB to separate VMs with packer.
- Create modules for App, DB and VPC in dir modules.
- Modify outputs to use app and db module instances.
- Run terraform get to apply modules. Check with tree .terraform.
- Create Stage and Prod infras to use the same modules (DRY forever).
- Correct path to modules. Format configs with terraform fmt.
- Get to know Terraform registry.
- * Configure remote backend to store state file. Check remote sharing of sate.
- ** Add provisioner to module app (templatefile to provide db-ip).
- ** Configure parameters to switch provisioner using (resource "null_recource" "deploy").
- Test with URL http://VM-app-ip:9292
- Create a configuration to run simple playbook.
- Analize running playbook: Playbook outputs changes made while running (in Yelloy:).
- *Try to make dynamical inventory.
- Create playbooks, handlers and templates.
- Switch Packer images from shell provisioner to Ansible playbooks.
Playbook variants:
- One playbok - One play.
- One playbok - Few plays.
- A few playbooks
Add *.retry to .gitignore
Get known with
--check
--limit
--tags
- import_playbook:
"provisioners": [
{
"type": "ansible",
"playbook_file": "ansible/packer_app.yml"
}
]packer build -var-file packer/variables.json packer/app.json
packer build -var-file packer/variables.json packer/db.json
terraform apply
ansible-playbook site.yml --limit appCheck with URL http://VM-app-ip:9292
- Create configuration to run simple playbook.
- Analize running playbook: Playbook outputs changes made while running (in Yelloy:).
- *Try to make dinamical inventory.