diodonfrost.terraform

ansible-role-terraform

molecule Ansible Galaxy

此角色用于在目标主机上安装 Terraform。

需求

此角色使用 Ansible 2.5 开发,向后兼容性无法保证。
使用 ansible-galaxy install diodonfrost.terraform 在您的系统上安装此角色。

  • Ansible >= 2.8
  • Python >= 2.7

角色变量

此角色有多个变量,以下是这些变量的默认设置:

---
# ansible-role-terraform 的默认文件

# 定义要安装的 Terraform 版本
# 可选值: https://releases.hashicorp.com/terraform/index.json
# 默认: latest
terraform_version: latest

# 定义下载 Terraform 软件包的 URL
# 默认: 使用 Ansible vars/*.yml 中定义的本地系统路径
terraform_pkg_url: "{{ __terraform_pkg_url }}"

# 定义安装 Terraform 二进制文件的位置
# 默认: 使用 Ansible vars/*.yml 中定义的本地系统路径
terraform_path: "{{ __terraform_default_path }}"

依赖

示例剧本

这是一个用于在局部环境中部署 Ansible Galaxy Terraform 角色并安装最新版本 Terraform 的示例剧本。

---
- hosts: localhost
  become: true
  roles:
    - role: diodonfrost.terraform

此角色也可以安装特定版本的 Terraform。

---
- hosts: localhost
  become: true
  roles:
    - role: ansible-role-terraform
      vars:
        terraform_version: 0.12.0-rc1

安装 Terraform 0.11.14

---
- hosts: localhost
  become: true
  roles:
    - role: ansible-role-terraform
      vars:
        terraform_version: 0.11.14

本地测试

此项目使用 Molecule 来帮助开发和测试。

要进行开发或测试,您需要安装以下内容:

使用 Docker 进行测试

# 安装需求
pip install -r requirements-dev.txt

# 使用 ubuntu 22.04 测试 ansible 角色
molecule test

# 使用 ubuntu 20.04 测试 ansible 角色
image=ansible-ubuntu:20.04 molecule test

# 使用 alpine 最新版测试 ansible 角色
image=ansible-alpine:latest molecule test

# 创建 centos 7 实例
image=ansible-centos:7 molecule create

# 在 centos 7 实例上应用角色
image=ansible-centos:7 molecule converge

# 在 centos 7 实例上启动测试
image=ansible-centos:7 molecule verify

使用 Vagrant 和 Libvirt 进行测试

# 使用 FreeBSD 测试 ansible 角色
molecule test -s freebsd

# 使用 OpenBSD 测试 ansible 角色
molecule test -s openbsd

# 使用 Windows 测试 ansible 角色
molecule test -s windows

许可

Apache 2

作者信息

此角色由 diodonfrost 于 2019 年创建。

关于项目

Ansible role for install the latest version of Terraform

安装
ansible-galaxy install diodonfrost.terraform
许可证
apache-2.0
下载
76k
拥有者