markdown 用于在Centos 7上创建VSI和安装Docker Engine的Terraform示例文件
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 用于在Centos 7上创建VSI和安装Docker Engine的Terraform示例文件相关的知识,希望对你有一定的参考价值。
## Export Variables
Substitute actual user and API key for `SL_USERNAME` and `SL_API_KEY`
```
export TF_VAR_slusername="SL_USERNAME"
export TF_VAR_slapikey="SL_API_KEY"
```
## Create terraform file
User will need to change the `pub_vlan` and `priv_vlan` default vaules to match the Vlans they want to deploy to:
```
variable slusername {}
variable slapikey {}
# The target operating system for the web nodes
variable os {
default = "CENTOS_7_64"
}
# The number of cores each web virtual guest will recieve
variable vm_cores {
default = 1
}
# The amount of memory each web virtual guest will recieve
variable vm_memory {
default = 2048
}
variable pub_vlan {
default = xxxxx
}
# The private vlan to deploy the virtual guests on to
variable priv_vlan {
default = xxxxx
}
provider "ibm" {
softlayer_username = "${var.slusername}"
softlayer_api_key = "${var.slapikey}"
}
resource "ibm_compute_vm_instance" "node" {
hostname = "myhost"
domain = "example.com"
os_reference_code = "${var.os}"
datacenter = "dal13"
network_speed = 1000
hourly_billing = true
private_network_only = false
cores = "${var.vm_cores}"
memory = "${var.vm_memory}"
disks = [100]
local_disk = false
public_vlan_id = "${var.pub_vlan}"
private_vlan_id = "${var.priv_vlan}"
provisioner "file" {
source = "postinstall.sh"
destination = "/tmp/postinstall.sh"
}
provisioner "remote-exec" {
inline = [
"chmod +x /tmp/postinstall.sh",
"/tmp/postinstall.sh",
]
}
}
```
## Post install script
```
#!/usr/bin/env bash
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce -y
```
以上是关于markdown 用于在Centos 7上创建VSI和安装Docker Engine的Terraform示例文件的主要内容,如果未能解决你的问题,请参考以下文章
markdown 如何在CentOS 7上安装Apache
markdown 在Centos 7.2上安装MariaDB 1.08 Columnstore
markdown Zabbix 3使用PostgreSQL 9.5在CEntOS 7上安装
如何在 CentOS 7 上安装 Docker
3-7 run vs cmd vsentrypoint
markdown PHP安装CentOS 7