Skip to content

Commit

Permalink
Merge pull request #2 from snifbr/extra-nginx-conf
Browse files Browse the repository at this point in the history
feat: habilitado vars nginx_extra_conf
  • Loading branch information
lgfa29 authored Nov 26, 2022
2 parents 15e9d7b + 82e87ef commit b2cbf7c
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 5 deletions.
14 changes: 14 additions & 0 deletions ansible/nginx_extra_conf/nomad.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
upstream traefik {
server 10.2.2.5:80;
server 10.2.2.4:80;
}

server {
listen 80;
server_name *.mentoriadevops.io;

location / {
proxy_pass http://traefik;
proxy_set_header Host $host;
}
}
10 changes: 7 additions & 3 deletions ansible/playbook.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
---
- name: hello world
- name: "load balancer"
hosts: default
become: true

roles:
- iac_role_nginx
- role: iac_role_nginx
vars:
nginx_version: 1.18.0-0ubuntu1.4
nginx_extra_files:
- filename: nginx_extra_conf/nomad.conf
destination: /etc/nginx/conf.d/nomad.conf
2 changes: 1 addition & 1 deletion ansible/requirements.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
- src: https://github.com/mentoriaiac/iac_role_nginx.git
scm: git
version: main
version: v0.1.0
14 changes: 13 additions & 1 deletion packer/packer.pkr.hcl
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# Packer Nginx
locals {
image_id = var.release != "" ? var.release : formatdate("YYYYMMDDhhmmss", timestamp())
}

source "googlecompute" "nginx" {
project_id = var.project_id
source_image = "ubuntu-2004-focal-v20220404"
ssh_username = "packer"
zone = "us-central1-a"

image_name = replace("nginx-${local.image_id}", ".", "-")
}

build {
Expand All @@ -13,7 +18,14 @@ build {
provisioner "ansible" {
playbook_file = "../ansible/playbook.yml"
galaxy_file = "../ansible/requirements.yml"
galaxy_force_install = true
galaxy_force_with_deps = true
user = "packer"
ansible_ssh_extra_args = ["-oPubkeyAcceptedKeyTypes=+ssh-rsa", " -oHostKeyAlgorithms=+ssh-rsa"]
ansible_env_vars = [
"ANSIBLE_REMOTE_TMP=/tmp/.ansible/tmp",
"ANSIBLE_SSH_ARGS='-oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedKeyTypes=ssh-rsa'",
"ANSIBLE_HOST_KEY_CHECKING=False"
]
#ansible_ssh_extra_args = ["-oPubkeyAcceptedKeyTypes=+ssh-rsa", " -oHostKeyAlgorithms=+ssh-rsa"]
}
}
1 change: 1 addition & 0 deletions packer/variables.auto.pkrvars.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
project_id = "mentoria-iac-staging"
6 changes: 6 additions & 0 deletions packer/variables.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ variable "project_id" {
type = string
description = "ID do projeto do google cloud"
}

variable "release" {
type = string
description = "Tag de release da pipeline de CI"
default = ""
}

0 comments on commit b2cbf7c

Please sign in to comment.