-
-
Save squioc/5fdcc5cb2b13e05441396122d841260c to your computer and use it in GitHub Desktop.
Devops rennes 2017 hands on Terraform Openstack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
docker pull jseguillon/openbox || docker pull jseguillon/openbox:alpine | |
git clone https://gist.github.com/2c2b2220a4b9e294733e6ff09966f591.git dops-ren && cd dops-ren | |
## | |
ssh-keygen -f ./openstack -b 4096 | |
#ovh 4096 key | |
docker run -d -it --name dops-ren --mount type=bind,source="$(pwd)",target=/usr/share/source jseguillon/openbox:alpine | |
#Or non alpine | |
docker exec -it dops-ren bash | |
## | |
terraform init | |
# installe les plugins nécessaires à l’infra | |
terraform plan --out plan | |
terraform show plan | |
terraform graph plan | |
## | |
terraform apply plan | |
export TF_LOG=DEBUG && export OS_DEBUG=1 | |
## | |
terraform show | grep -E 'instance|ip_v4' | |
## | |
terraform plan --destroy --out destroy | |
terraform apply destroy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import de la clé SSH au sein d'OpenStack | |
resource "openstack_compute_keypair_v2" "test_keypair" { | |
provider = "openstack" # Nom du fournisseur déclaré dans provider.tf | |
name = "test_keypair" # Nom de la clé SSH à utiliser pour la création | |
public_key = "${file("./openstack.pub")}" # Chemin vers votre clé SSH précédemment générée | |
region = "GRA3" | |
} | |
# Création d'une machine virtuelle OpenStack | |
resource "openstack_compute_instance_v2" "dops-ren-ub" { | |
name = "dops-ren-ub" # Nom de l'instance | |
provider = "openstack" # Nom du fournisseur | |
image_name = "Ubuntu 16.04" # Nom de l'image | |
flavor_name = "s1-2" # Nom du type de machine | |
region = "GRA3" | |
# Nom de la ressource openstack_compute_keypair_v2 no mmé test_keypair | |
key_pair = "${openstack_compute_keypair_v2.test_keypair.name}" | |
network { | |
name = "Ext-Net" # Ajoute le réseau public à votre instance | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
provider "openstack" { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment