First, you need to have wsl installed on your device! without it you can't benefit from anything here! Actually, all the .bat scripts mostly calles their alternatives in wsl. So, to setup the scripts, Run the following script
path> .\scripts\setup\windowsRun the following script
./scripts/setup/linuxusually, when you use this repository as a template, you will find a lot of stuff named changeme, you can find them all and replace them with the appropriate configurations
the basic structure of a project is like the following:
project_dir
├── README.md (1) this documentation
├── ansible (2) all your ansible stuff...
│ ├── ansible.cfg
│ ├── playbook.yaml
│ ├── static
│ │ └── all your static files...
│ └── templates
│ └── all your templates...
├── envs (3) environment/workspace specific data
│ ├── beta
│ │ └── inventory (4) an example of what can be in an environment
│ │ ├── foo.yaml
│ │ └── bar.yaml
│ ├── dev
│ │ └── ...
│ └── prod
│ └── ...
├── scripts (5) for scripts
│ └── all your scripts...
├── ter.bat (6) ter script for windows (git ignored)
├── ans.bat (7) ans script for windows (git ignored)
└── terraform (8) all your terraform code
├── ecr_repos.tf
├── vars.tfvars (9) variables for terraform
├── {env}.tfvars (10) environment variables for terraform
├── locals.tf
├── providers.tf
└── all your terraform code...instead of changing directory into the terraform directory and running terraform, you can just run ter, and this is a script that runs terraform with the flag -chdir set to terraform, and run all your terraform commands easily
$ ter plan
$ ter apply --auto-approve
$ ter state list
...etc.the template comes with predefined aws provider, some aws resources in the common module, and you can edit this as for every project needs. it also commes with predefined variables to make your life a little bit more easier and efficient, but there's some of them that needs manual configuration from you, and this locals/variables will usually be set to 'changeme', as described earlier.
the ter command automaticly adds the arguments -var-file=vars.tfvars -var-file={env}.tfvars to the terraform command on the plan,apply,destroy subcommands
this variable refer to the project's root directory which contains the terraform, ansible...etc. directories
this refers to the ./envs/${current environment} directory
current environment determined by the workspace
since we like dev and beta resources to have the -dev or -beta suffix at the end, but not in production, this variable is made specificly for that reason. in dev and beta environments it will be rendered as -dev or -beta, but in production it will be empty
dev => -dev
beta => -beta
prod => (empty)
since we like dev and beta domains to have the dev. or beta. prefix at the beggining, but not in production, this variable is made specificly for that reason. in dev and beta environments it will be rendered as dev. or beta., but in production it will be empty
dev => dev.
beta => beta.
prod => (empty)
so if this is set for the domain api.mafazaa.com for example, you can safely enter "${local.domain_env}api.mafazaa.com", and it will be rendered correctly in the three environments:
dev => dev.api.mafazaa.com
beta => beta.api.mafazaa.com
prod => api.mafazaa.com
instead of specifiying inventory, making sure that ansible is using ansible.cfg, this is a script that gets the environment of the current terraform workspace using the ter command described earlier, then runs ansible-playbook while specifiying the appropriate inventory directory using that env variable, all that remains is specifiyng the ansible playbook, and any additional arguments
$ ans ansible/playbook.yamlthe inventory should be automatically generated using terraform, that's all about it