Skip to content
Snippets Groups Projects
Commit 940c00de authored by Diaz de Arcaya Serrano, Josu's avatar Diaz de Arcaya Serrano, Josu
Browse files

Adjust repository format according to issue #1

parent d356e2fb
No related branches found
No related tags found
No related merge requests found
.terraform*
terraform.tfstate*
inventory
---
iac:
- stage1
- stage2
...
#!/bin/bash
# A POSIX variable
OPTIND=1 # Reset in case getopts has been used previously in the shell.
usage="usage: landing-script.sh [-h] [-i] [-a] [-d]
This script serves as the entrypoint for the IEM
arguments:
-h show this help message and exit
-i init configuration
-a create or update infrastructure
-d destroy infrastructure"
init() {
# the following line is only for testing purposes
ssh-keygen -f ~/.ssh/id_rsa -N "" <<< n
# the line above is only for testing purposes
terraform init
}
apply() {
terraform apply -auto-approve
}
destroy() {
terraform destroy -auto-approve
}
while getopts "h?iad" opt; do
case "$opt" in
h|\?)
echo "$usage"
exit 0
;;
i) init
;;
a) apply
;;
d) destroy
;;
esac
done
......@@ -29,23 +29,6 @@ resource "aws_instance" "server0" {
instance_type = local.instance_type
key_name = "deployer-key"
provisioner "remote-exec" {
inline = [
"sudo apt update",
"sudo apt install nginx -y",
]
connection {
type = "ssh"
host = self.public_ip
user = "ubuntu"
private_key = "${file("~/.ssh/id_rsa")}"
}
}
provisioner "local-exec" {
command = "ansible-playbook -u ubuntu -i '${self.public_ip},' client.yml"
}
tags = {
Name = "hello-nginx"
}
......
---
input:
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
output:
- instance_server0_ip
engine: terraform
...
File moved
---
input:
- instance_server0_ip
engine: ansible
...
File moved
[all:vars]
ansible_user=ubuntu
[server0]
server0.piacere.com ansible_host={{ instance_server0_ip }}
......@@ -4,7 +4,7 @@
tasks:
- name: Install necessary packages
apt:
name: python3-pip
name: nginx
state: latest
update_cache: yes
- name: copy html
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment