我让Jenkins在EC2实例上运行。我在对等VPC中配置了EC2插件,当作业标记为“ support_ubuntu_docker”时,它将启动Jenkins Slave,并预安装了Docker。
我能够按照示例操作,并让我的工作连接到在Slave上运行的本地docker,并在容器内运行命令。
工作:https://pastebin.com/UANvjhnA
pipeline {
agent {
docker {
image 'node:7-alpine'
label 'support_ubuntu_docker'
}
}
stages {
stage('Test') {
steps {
sh 'node --version'
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
不起作用https://pastebin.com/MsSZaPha
pipeline {
agent {
docker {
image 'hashicorp/terraform:light'
label 'support_ubuntu_docker'
}
}
stages {
stage('Test') {
steps {
sh 'terraform --version'
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用ansible / ansible:default图像以及我自己创建的图像。
FROM alpine:3.7
RUN apk add --no-cache terraform
RUN apk add --no-cache ansible
ENTRYPOINT ["/bin/ash"]
Run Code Online (Sandbox Code Playgroud)
此图像在本地运行。
[jenkins_test] docker …
Run Code Online (Sandbox Code Playgroud) 我有一个模板文件,它正在创建一个 fluentd 文件并插入各种变量。我现在试图包含这个插件 ,它希望在配置文件中找到它自己的变量。问题是 Terraform 在模板中定义了一个变量${variable}
,这个插件希望在文件中找到它的变量作为文字${variable}
如何告诉 terraform 不要${}
在文件中插入 a ,而是实际传递整个字符串?
文件片段:
<filter tomcat.logs>
@type record_transformer
<record>
customer ${customer}
environment ${environment}
application ${application}
</record>
</filter>
Run Code Online (Sandbox Code Playgroud)
以上${}
是我为模板定义的所有变量。我现在需要添加一个这样的部分。
<record>
hostname ${tagset_name}
instance_id ${instance_id}
instance_type ${instance_type}
az ${availability_zone}
private_ip ${private_ip}
vpc_id ${vpc_id}
ami_id ${image_id}
account_id ${account_id}
</record>
Run Code Online (Sandbox Code Playgroud)
所有这些都是不变量,但它是如何实际需要渲染的模板的样子。我尝试将它们交换为 like $${account_id}
,但这最终只会在文件中呈现 account_id 。
data "template_file" "app" {
template = "${file("templates/${var.application}.tpl")}"
vars {
customer = "${var.customer}"
environment = "${var.environment}"
application = "${var.application}"
}
} …
Run Code Online (Sandbox Code Playgroud)