This is an example of how to use Jenkins pipeline to build infrastructe and deploy Symfony Demo Application. In following case is used Terraform to create VM, ansible to configure VM, install and configure nginx, postgres and some packages.
- Terraform using such providers as DigitalOcean, AWS. So you must have the required accounts
- To create and configure VM in stage('Create VM') in Jenkinsfile you are to specify agent on which is already installed "terraform >= 0.13" and ansible >= 2.7"
- Fill in all needed credentials in Jenkins Credentials and variables into Jenkinsfile Environment.
- Fill in Droplet variables into terraform.tfvars
- Sincronise variable "dnsrecord" in Jenkinsfile and terraform.tfvars
Do not use secret data in the open form in Jenkinsfiles, ansible playbooks, or direct indication in variables. It's much more better to use Jenkins Credentials as a secret store and use them as passed arguments when executing commands.