diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..1b0afd741aa08616f90c87e317ff0f30da9c48c6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,92 @@ +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +### Packer ### +# Cache objects +packer_cache/ + +# Crash log +crash.log + +# https://www.packer.io/guides/hcl/variables +# Exclude all .pkrvars.hcl files, which are likely to contain sensitive data, +# such as password, private keys, and other secrets. These should not be part of +# version control as they are data points which are potentially sensitive and +# subject to change depending on the environment. +# +*.pkrvars.hcl + +# For built boxes +*.box + +### Packer Patch ### +# ignore temporary output files +output-*/ + +### Terraform ### +# Local .terraform directories +**/.terraform/* + +# .tfstate files +*.tfstate +*.tfstate.* + +# Crash log files +crash.*.log + +# Exclude all .tfvars files, which are likely to contain sensitive data, such as +# password, private keys, and other secrets. These should not be part of version +# control as they are data points which are potentially sensitive and subject +# to change depending on the environment. +*.tfvars +*.tfvars.json + +# Ignore override files as they are usually used to override resources locally and so +# are not checked in +override.tf +override.tf.json +*_override.tf +*_override.tf.json + +# Include override files you do wish to add to version control using negated pattern +# !example_override.tf + +# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan +# example: *tfplan* + +# Ignore CLI configuration files +.terraformrc +terraform.rc + +.terraform.lock.hcl +formation-cnrs-docker diff --git a/exemples-terraform/base-nginx/main.tf b/exemples-terraform/base-nginx/main.tf new file mode 100644 index 0000000000000000000000000000000000000000..b91bb635b2561bd1e0eb199846fac2a1e2431a15 --- /dev/null +++ b/exemples-terraform/base-nginx/main.tf @@ -0,0 +1,30 @@ +terraform { + required_providers { + docker = { + source = "kreuzwerker/docker" + version = "3.0.2" + } + } +} + +variable "docker_api_path" { + type = string + description = "Chemin d'accès à l'API (via tcp ou unix)" +} + +provider "docker" { + # Pour un hôte linux, déclaration de l'hôte : + # "unix:///var/run/docker.sock" + # Adaptation pour macOS : + # "unix:///$HOME/.docker/run/docker.sock" + host = var.docker_api_path +} + +resource "docker_container" "terraform_container" { + image = "local/ubu-form-cnrs-nginx:22.04.2" + name = "nginx_via_terraform" + ports { + internal = "80" + external = "5555" + } +} \ No newline at end of file diff --git a/exemples-terraform/stack-wordpress/formation-docker-cnrs b/exemples-terraform/stack-wordpress/formation-docker-cnrs new file mode 100644 index 0000000000000000000000000000000000000000..37ad6d8cdabc8c4b38140880cde443940bc65631 Binary files /dev/null and b/exemples-terraform/stack-wordpress/formation-docker-cnrs differ diff --git a/exemples-terraform/stack-wordpress/main.tf b/exemples-terraform/stack-wordpress/main.tf new file mode 100644 index 0000000000000000000000000000000000000000..95f93ce02349a9cd36604d351aee42640743aef6 --- /dev/null +++ b/exemples-terraform/stack-wordpress/main.tf @@ -0,0 +1,69 @@ +terraform { + required_providers { + docker = { + source = "kreuzwerker/docker" + version = "3.0.2" + } + } +} + +variable "docker_api_path" { + type = string + description = "Chemin d'accès à l'API (via tcp ou unix)" +} + +provider "docker" { + host = var.docker_api_path +} + +resource "docker_network" "private_network" { + name = "wpnet_form_docker" +} + +resource "docker_volume" "wpdb_form_docker" { + name = "wpdb_form_docker" +} + +resource "docker_volume" "wphtml_form_docker" { + name = "wphtml_form_docker" +} + +resource "docker_container" "db_form_docker" { + name = "db" + image = "mariadb:latest" + restart = "always" + network_mode = "wpnet_form_docker" + mounts { + type = "volume" + target = "/var/lib/mysql" + source = "wpdb_form_docker" + } + env = [ + "MYSQL_ROOT_PASSWORD=mdprootmysql", + "MYSQL_DATABASE=wordpress", + "MYSQL_USER=wpuser", + "MYSQL_PASSWORD=wppassword" + ] +} + +resource "docker_container" "wordpress_form_docker" { + name = "wordpress" + image = "wordpress:latest" + restart = "always" + network_mode = "wpnet_form_docker" + env = [ + "WORDPRESS_DB_HOST=db", + "WORDPRESS_DB_USER=wpuser", + "WORDPRESS_DB_PASSWORD=wppassword", + "WORDPRESS_DB_NAME=wordpress" + ] + ports { + internal = "80" + external = "5555" + } + mounts { + type = "volume" + target = "/var/www/html" + source = "wphtml_form_docker" + } +} \ No newline at end of file