Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit a20bd1d3 authored by Jean-François HOVINNE's avatar Jean-François HOVINNE
Browse files

Pull request #1: ECGALAXY-46: Implement role

* commit '38ad39f8':
  ECGALAXY-46: Fix readme
  ECGALAXY-46: Implement role
parents d4cb7af4 38ad39f8
Branches
Tags 0.1.0
No related merge requests found
---
# Based on ansible-lint config
extends: default
rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
colons:
max-spaces-after: -1
level: error
commas:
max-spaces-after: -1
level: error
comments: disable
comments-indentation: disable
document-start: disable
empty-lines:
max: 3
level: error
hyphens:
level: error
indentation: disable
key-duplicates: enable
line-length: disable
new-line-at-end-of-file: disable
new-lines:
type: unix
trailing-spaces: disable
truthy: disable
......@@ -16,15 +16,14 @@ See `vars` folder.
Dependencies
------------
* ecgalaxy.bootstrap
None.
Example Playbook
----------------
- hosts: all
roles:
- ecgalaxy.bootstrap
- ecgalaxy.terraform
- terraform
License
-------
......
---
galaxy_info:
name: terraform
author: ecgalaxy
description: HashiCorp Terraform
company: European Commission
license: EUPL-1.2
min_ansible_version: 2.5
platforms:
- name: Amazon Linux 2
versions:
- all
- name: EL
versions:
- 7
- 8
- name: Ubuntu
versions:
- bionic
- focal
galaxy_tags: []
dependencies: []
---
- name: Converge
hosts: all
tasks:
- name: "Include terraform"
include_role:
name: "terraform"
environment:
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
no_proxy: "{{ lookup('env', 'no_proxy') }}"
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: amazonlinux2
image: geerlingguy/docker-amazonlinux2-ansible:latest
pre_build_image: true
env:
http_proxy: "${http_proxy}"
https_proxy: "${https_proxy}"
no_proxy: "${no_proxy}"
- name: centos7
image: geerlingguy/docker-centos7-ansible:latest
pre_build_image: true
env:
http_proxy: "${http_proxy}"
https_proxy: "${https_proxy}"
no_proxy: "${no_proxy}"
- name: centos8
image: geerlingguy/docker-centos8-ansible:latest
pre_build_image: true
env:
http_proxy: "${http_proxy}"
https_proxy: "${https_proxy}"
no_proxy: "${no_proxy}"
- name: ubuntu1804
image: geerlingguy/docker-ubuntu1804-ansible:latest
pre_build_image: true
env:
http_proxy: "${http_proxy}"
https_proxy: "${https_proxy}"
no_proxy: "${no_proxy}"
- name: ubuntu2004
image: geerlingguy/docker-ubuntu2004-ansible:latest
pre_build_image: true
env:
http_proxy: "${http_proxy}"
https_proxy: "${https_proxy}"
no_proxy: "${no_proxy}"
provisioner:
name: ansible
log: true
config_options:
defaults:
callback_whitelist: profile_tasks, timer, yaml
verifier:
name: ansible
lint: |
set -e
yamllint .
ansible-lint .
---
- name: Prepare
hosts: all
tasks:
- name: Update apt cache
apt: update_cache=yes cache_valid_time=600
when: ansible_os_family == 'Debian'
changed_when: false
- name: Install terraform installer dependencies
apt:
name:
- gpg-agent
state: present
when: ansible_os_family == 'Debian'
changed_when: false
environment:
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
no_proxy: "{{ lookup('env', 'no_proxy') }}"
become: true
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Check binary file
stat:
path: /usr/bin/terraform
register: bin
- name: Assert that terraform is installed
assert:
that:
- "bin.stat.exists"
- name: Check terraform execution
command: terraform -version
register: output
- name: Assert that terraform is installed
assert:
that:
- "'Terraform' in output.stdout"
---
- name: Include OS-specific variables
include_vars: "{{ ansible_os_family }}.yml"
- name: Include Distribution-specific variables (Amazon Linux)
include_vars: "{{ ansible_distribution }}.yml"
when: ansible_distribution == 'Amazon'
- name: Import key (APT)
apt_key:
url: "{{ hashicorp_repository }}/gpg"
state: present
become: true
when: ansible_os_family == 'Debian'
- name: Enable hashicorp repository (APT)
apt_repository:
repo: "deb [arch=amd64] {{ hashicorp_repository }} {{ ansible_distribution_release | lower }} main"
filename: hashicorp
state: present
become: true
when: ansible_os_family == 'Debian'
- name: Enable hashicorp repository (Yum)
yum_repository:
name: hashicorp
description: HashiCorp repository
state: present
baseurl: "{{ hashicorp_repository }}/{{ hashicorp_rpm_family }}/$releasever/$basearch/stable"
gpgkey: "{{ hashicorp_repository }}/gpg"
gpgcheck: yes
become: true
when: ansible_os_family == 'RedHat'
- name: Install terraform
package:
name: terraform
state: present
become: true
---
hashicorp_rpm_family: "AmazonLinux"
---
hashicorp_repository: "https://apt.releases.hashicorp.com"
---
hashicorp_repository: "https://rpm.releases.hashicorp.com"
hashicorp_rpm_family: "RHEL"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment