-
Notifications
You must be signed in to change notification settings - Fork 7
/
sample.tf
183 lines (156 loc) · 4.5 KB
/
sample.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
terraform {
required_providers {
pipeline = {
source = "jfrog/pipeline"
version = "1.2.4"
}
project = {
source = "jfrog/project"
version = "1.5.1"
}
artifactory = {
source = "jfrog/artifactory"
version = "10.3.3"
}
}
}
variable "artifactory_url" {
type = string
default = "http://localhost:8081"
}
provider "pipeline" {
url = var.artifactory_url
}
provider "project" {
url = var.artifactory_url
}
provider "artifactory" {
url = var.artifactory_url
}
# Artifactory resources
resource "artifactory_local_docker_v2_repository" "docker-local" {
key = "docker-v2-local"
tag_retention = 3
max_unique_tags = 5
}
resource "artifactory_user" "user-1" {
name = "user1"
email = "[email protected]"
groups = ["readers"]
password = "my super secret password"
}
resource "artifactory_user" "user-2" {
name = "user2"
email = "[email protected]"
groups = ["readers"]
password = "my super secret password"
}
# Projects resources
variable "qa_roles" {
type = list(string)
default = ["READ_REPOSITORY", "READ_RELEASE_BUNDLE", "READ_BUILD", "READ_SOURCES_PIPELINE", "READ_INTEGRATIONS_PIPELINE", "READ_POOLS_PIPELINE", "TRIGGER_PIPELINE"]
}
variable "devop_roles" {
type = list(string)
default = ["READ_REPOSITORY", "ANNOTATE_REPOSITORY", "DEPLOY_CACHE_REPOSITORY", "DELETE_OVERWRITE_REPOSITORY", "TRIGGER_PIPELINE", "READ_INTEGRATIONS_PIPELINE", "READ_POOLS_PIPELINE", "MANAGE_INTEGRATIONS_PIPELINE", "MANAGE_SOURCES_PIPELINE", "MANAGE_POOLS_PIPELINE", "READ_BUILD", "ANNOTATE_BUILD", "DEPLOY_BUILD", "DELETE_BUILD", ]
}
resource "project" "myproject" {
key = "myproj"
display_name = "My Project"
description = "My Project"
admin_privileges {
manage_members = true
manage_resources = true
index_resources = true
}
max_storage_in_gibibytes = 10
block_deployments_on_limit = false
email_notification = true
member {
name = artifactory_user.user-1.name
roles = ["Developer", "Project Admin"]
}
member {
name = artifactory_user.user-2.name
roles = ["Developer"]
}
group {
name = "qa"
roles = ["qa"]
}
group {
name = "release"
roles = ["Release Manager"]
}
role {
name = "qa"
description = "QA role"
type = "CUSTOM"
environments = ["DEV"]
actions = var.qa_roles
}
role {
name = "devop"
description = "DevOp role"
type = "CUSTOM"
environments = ["DEV", "PROD"]
actions = var.devop_roles
}
repos = [artifactory_local_docker_v2_repository.docker-local.key]
}
# Pipelines resources
data "pipeline_project" "my-project" {
name = project.myproject.key
}
resource "pipeline_project_integration" "my-project-integration" {
name = "my-project-integration"
project {
key = project.myproject.key
name = project.myproject.display_name
}
master_integration_id = 0
master_integration_name = "my-master-integration"
environments = ["DEV"]
is_internal = false
form_json_values {
label = "label-1"
value = "value-1"
}
form_json_values {
label = "label-2"
value = "value-2"
is_sensitive = true
}
}
resource "pipeline_source" "my-pipeline-source" {
name = "my-pipeline-source"
project_id = data.pipeline_project.my-project.id
project_integration_id = pipeline_project_integration.my-project-integration.id
repository_full_name = "myrepo/docker-sample"
file_filter = "pipelines.yml"
is_multi_branch = false
branch = "main"
branch_exclude_pattern = "debug"
branch_include_pattern = "features"
environments = ["DEV"]
template_id = 0
}
resource "pipeline_node_pool" "my-node-pool" {
name = "my-node-pool"
project_id = data.pipeline_project.my-project.id
number_of_nodes = 1
is_on_demand = true
architecture = "x86_64"
operating_system = "Ubuntu_18.04"
node_idle_interval_in_mins = 20
environments = ["DEV"]
}
resource "pipeline_node" "my-node" {
friendly_name = "my-node"
project_id = data.pipeline_project.my-project.id
node_pool_id = pipeline_node_pool.my-node-pool.id
is_on_demand = true
is_auto_initialized = true
ip_address = "10.0.0.1"
is_swap_enabled = true
}