Skip to content

Commit

Permalink
[Lazy - Ansible] Introduce terraform
Browse files Browse the repository at this point in the history
  • Loading branch information
nervo committed Dec 2, 2023
1 parent 45f3d04 commit b81a148
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lazy.ansible/.manala.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,7 @@ system:
version: ~
# @schema {"items": {"type": "string"}}
dependencies: []
terraform:
# @schema {"enum": [null, "1.5.7"]}
# @option {"label": "Terraform version"}
version: ~
6 changes: 6 additions & 0 deletions lazy.ansible/.manala.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,9 @@ system:
# - molecule-plugins==23.0.0
# - molecule-plugins[docker]==23.0.0
{{- end }}

{{- $terraform := .Vars.system.terraform }}
{{- if $terraform.version }}
terraform:
version: {{ $terraform.version | toYaml }}
{{- end }}
16 changes: 16 additions & 0 deletions lazy.ansible/.manala/docker/Dockerfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,22 @@ RUN \

{{ end -}}

{{ $terraform := .Vars.system.terraform -}}
{{ if $terraform.version -}}
# Terraform
RUN \
curl -sSL "https://releases.hashicorp.com/terraform/{{ $terraform.version }}/terraform_{{ $terraform.version }}_linux_{{ include "arch_map" (dict "amd64" "amd64" "arm64" "arm64") }}.zip" \
| bsdtar -xvf - -C /usr/local/bin \
&& chmod +x /usr/local/bin/terraform \
# Bash completion
&& echo "complete -C /usr/local/bin/terraform terraform" > /etc/bash_completion.d/terraform \
# Bash aliases
&& printf "alias tf='terraform'\n\
complete -C /usr/local/bin/terraform tf\n\
" > /etc/profile.d/terraform.sh

{{ end -}}

# Run
COPY docker/entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
Expand Down
4 changes: 4 additions & 0 deletions lazy.ansible/.manala/etc/profile.d/message.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ printf " \033[36m‣ molecule \033[35m{{ $molecule.version }}\033[0m\n"
printf " \033[36m· {{ $dependency }}\033[0m\n"
{{- end }}
{{- end }}
{{- $terraform := .Vars.system.terraform }}
{{- if $terraform.version }}
printf " \033[36m‣ terraform \033[35m{{ $terraform.version }}\033[0m\n"
{{- end }}

{{- $help := .Vars.project.help }}
{{- if $help }}
Expand Down
2 changes: 2 additions & 0 deletions lazy.ansible/test/.manala.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ system:
dependencies:
- molecule-plugins==23.5.0
- molecule-plugins[docker]==23.5.0
terraform:
version: 1.5.7
5 changes: 5 additions & 0 deletions lazy.ansible/test/goss.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,8 @@ command:
stdout:
- "/molecule(\\s+){{ .Vars.system.molecule.version }}/"
- "/molecule-plugins(\\s+)\\d+\\.\\d+\\.\\d+/"
# Terraform
terraform -version:
exit-status: 0
stdout:
- Terraform v{{ .Vars.system.terraform.version }}

0 comments on commit b81a148

Please sign in to comment.