diff --git a/Days/IaC/Virtualbox/virtualbox.tf b/Days/IaC/Virtualbox/virtualbox.tf new file mode 100644 index 0000000..c85e31d --- /dev/null +++ b/Days/IaC/Virtualbox/virtualbox.tf @@ -0,0 +1,31 @@ +terraform { + required_providers { + virtualbox = { + source = "terra-farm/virtualbox" + version = "0.2.2-alpha.1" + } + } +} + +# There are currently no configuration options for the provider itself. + +resource "virtualbox_vm" "node" { + count = 2 + name = format("node-%02d", count.index + 1) + image = "https://app.vagrantup.com/ubuntu/boxes/bionic64/versions/20180903.0.0/providers/virtualbox.box" + cpus = 2 + memory = "512 mib" + + network_adapter { + type = "hostonly" + host_interface = "vboxnet1" + } +} + +output "IPAddr" { + value = element(virtualbox_vm.node.*.network_adapter.0.ipv4_address, 1) +} + +output "IPAddr_2" { + value = element(virtualbox_vm.node.*.network_adapter.0.ipv4_address, 2) +} \ No newline at end of file diff --git a/Days/Images/Day59_IAC2.png b/Days/Images/Day59_IAC2.png new file mode 100644 index 0000000..dea8aa7 Binary files /dev/null and b/Days/Images/Day59_IAC2.png differ diff --git a/Days/Images/Day59_IAC3.png b/Days/Images/Day59_IAC3.png new file mode 100644 index 0000000..8c703be Binary files /dev/null and b/Days/Images/Day59_IAC3.png differ diff --git a/Days/Images/Day59_IAC4.png b/Days/Images/Day59_IAC4.png new file mode 100644 index 0000000..a4a06c3 Binary files /dev/null and b/Days/Images/Day59_IAC4.png differ diff --git a/Days/Images/Day59_IAC5.png b/Days/Images/Day59_IAC5.png new file mode 100644 index 0000000..44c0324 Binary files /dev/null and b/Days/Images/Day59_IAC5.png differ diff --git a/Days/Images/Day59_IAC6.png b/Days/Images/Day59_IAC6.png new file mode 100644 index 0000000..fc2e068 Binary files /dev/null and b/Days/Images/Day59_IAC6.png differ diff --git a/Days/day59.md b/Days/day59.md index be56a46..0d008a9 100644 --- a/Days/day59.md +++ b/Days/day59.md @@ -6,28 +6,69 @@ Purely demo purpose but the concept is the same we are going to have our desired ### Create virtual machine in VirtualBox -The first thing we are going to do is create a new folder called virtualbox, we can then create a virtualbox.tf file and this is going to be where we define our resources. +The first thing we are going to do is create a new folder called virtualbox, we can then create a virtualbox.tf file and this is going to be where we define our resources. The code below which can be found in the VirtualBox folder as virtualbox.tf this is going to create 2 VMs in Virtualbox. +``` +terraform { + required_providers { + virtualbox = { + source = "terra-farm/virtualbox" + version = "0.2.2-alpha.1" + } + } +} - +# There are currently no configuration options for the provider itself. + +resource "virtualbox_vm" "node" { + count = 2 + name = format("node-%02d", count.index + 1) + image = "https://app.vagrantup.com/ubuntu/boxes/bionic64/versions/20180903.0.0/providers/virtualbox.box" + cpus = 2 + memory = "512 mib" + + network_adapter { + type = "hostonly" + host_interface = "vboxnet1" + } +} + +output "IPAddr" { + value = element(virtualbox_vm.node.*.network_adapter.0.ipv4_address, 1) +} + +output "IPAddr_2" { + value = element(virtualbox_vm.node.*.network_adapter.0.ipv4_address, 2) +} + +``` Now that we have our code defined we can now perform the `terraform init` on our folder to download the provider for virtualbox. ![](Images/Day59_IAC1.png) -Obviously you will also need to have virtualbox installed on your system as well. We can then next run `terraform plan` to see what our code will create for us. Followed by `terraform apply` +Obviously you will also need to have virtualbox installed on your system as well. We can then next run `terraform plan` to see what our code will create for us. Followed by `terraform apply` the below image shows your completed process. +![](Images/Day59_IAC2.png) +In Virtualbox you will now see your 2 virtual machines. +![](Images/Day59_IAC3.png) -### Change configuration so that it then becomes a web server +### Change configuration +Lets add another node to our deployment. We can simply change the count line to show our newly desired number of nodes. When we run our `terraform apply` it will look something like below. +![](Images/Day59_IAC4.png) -### Add additional virtual machine to change our desired state +Once complete in virtualbox you can see we now have 3 nodes up and running. +![](Images/Day59_IAC5.png) +When we are finished we can clear this up using the `terraform destroy` and our machines will be removed. + +![](Images/Day59_IAC6.png) ### Variables & Outputs @@ -60,19 +101,6 @@ variable "some resource" { } ``` - - - -Variables and Outputs -Additional Language Features -Project Organization + Modules -Managing Multiple Environments -Testing Terraform Code -Developer Workflows and Automation - - - - ## Resources I have listed a lot of resources down below and I think this topic has been covered so many times out there, If you have additional resources be sure to raise a PR with your resources and I will be happy to review and add them to the list. diff --git a/Days/day60.md b/Days/day60.md index 010ec38..edc9540 100644 --- a/Days/day60.md +++ b/Days/day60.md @@ -1,5 +1,10 @@ ## Docker Containers, Provisioners & Modules +On [Day 59](day59.md) we provisioned a virtual machine using Terraform to our local FREE virtualbox environment. In this section we are going to be deploy a Docker container with some configuration to our local Docker environment. + + + + Docker demo `terraform init` diff --git a/Days/day62.md b/Days/day62.md index 6056254..f53eac6 100644 --- a/Days/day62.md +++ b/Days/day62.md @@ -1,8 +1,38 @@ -## +## Testing, Tools & Alternatives + +### Code Rot + +- Out of band changes +- Unpinned versions +- Deprecated dependancies +- Unapplied changes + +### Testing + +Built in + +- terraform fmt +- terraform validate +- terraform plan +- custom validation rules + +External tools +- tflint +- Scanning tools - checkov, tfsec, terrascan, terraform-compliance, snyk +- Managed Cloud offering - terraform sentinal + +Automated testing - Terratest / Shell Scripts + +Terraform Cloud Terragrunt -Terraform Cloud +runatlantis.io + +### Alternatives + +Pulumi + ## Resources I have listed a lot of resources down below and I think this topic has been covered so many times out there, If you have additional resources be sure to raise a PR with your resources and I will be happy to review and add them to the list. diff --git a/Days/day71.md b/Days/day71.md index e69de29..fd9f386 100644 --- a/Days/day71.md +++ b/Days/day71.md @@ -0,0 +1,9 @@ +## GitHub Actions Overview + +Ideas and it might be an overview and then additional day on demo ideas. + +https://github.blog/2022-02-02-build-ci-cd-pipeline-github-actions-four-steps/ + +GitHub Actions - Send tweet when a git push is performed - https://www.daveabrock.com/2020/04/19/posting-to-twitter-from-gh-actions/ + +GitHub Actions - Publish posts to dev.to - https://github.com/marketplace/actions/publish-to-dev-to \ No newline at end of file diff --git a/README.md b/README.md index 166a584..34bd7eb 100644 --- a/README.md +++ b/README.md @@ -98,12 +98,12 @@ This will not cover all things DevOps but it will cover the areas that I feel wi - [✔️] 🤖 59 > [Create a VM with Terraform & Variables](Days/day59.md) - [✔️] 🤖 60 > [Docker Containers, Provisioners & Modules](Days/day60.md) - [✔️] 🤖 61 > [Kubernetes & Multiple Environments](Days/day61.md) -- [🚧] 🤖 62 > [](Days/day62.md) +- [✔️] 🤖 62 > [Testing, Tools & Alternatives](Days/day62.md) ### Automate Configuration Management -- [] 📜 63 > [The Big Picture: Configuration Management](Days/day63.md) -- [] 📜 64 > [](Days/day64.md) +- [🚧] 📜 63 > [The Big Picture: Configuration Management](Days/day63.md) +- [] 📜 64 > [Ansible: Getting Started](Days/day64.md) - [] 📜 65 > [](Days/day65.md) - [] 📜 66 > [](Days/day66.md) - [] 📜 67 > [](Days/day67.md) @@ -113,7 +113,7 @@ This will not cover all things DevOps but it will cover the areas that I feel wi ### Create CI/CD Pipelines - [] 🔄 70 > [The Big Picture: CI/CD Pipelines](Days/day70.md) -- [] 🔄 71 > [](Days/day71.md) +- [] 🔄 71 > [GitHub Actions Overview](Days/day71.md) - [] 🔄 72 > [](Days/day72.md) - [] 🔄 73 > [](Days/day73.md) - [] 🔄 74 > [](Days/day74.md)