Skip to content

Commit fd61d10

Browse files
authored
feat(github): archive ansible repositories (#6)
## Summary - archive the listed ansible repositories in Terraform - stop managing branch protections and Actions secrets for archived repositories - keep the archived repository set explicit in locals ## Validation - make test
1 parent c109728 commit fd61d10

4 files changed

Lines changed: 39 additions & 56 deletions

File tree

gh-protections.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
*/
88

99
resource "github_branch_protection" "protections" {
10-
for_each = local.github_repositories
10+
for_each = toset([for repo in local.github_repositories : repo if !contains(local.archived_github_repositories, repo)])
1111
repository_id = github_repository.repositories[each.key].node_id
1212
pattern = "main"
1313
enforce_admins = false

gh-repositories.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
resource "github_repository" "repositories" {
1010
for_each = local.github_repositories
1111
name = each.key
12+
archived = contains(local.archived_github_repositories, each.key)
1213
visibility = var.github_visibility
1314
allow_squash_merge = true
1415
allow_merge_commit = true

main.tf

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ locals {
1919
"tfroot-libvirt",
2020
"www"
2121
])
22+
archived_github_repositories = toset([
23+
"ansible-project-libvirt",
24+
"ansible-site-cluster",
25+
"ansible-role-crc"
26+
])
2227
secrets = {
2328
"onion_s3_bucket" = {
2429
name = "ONION_AWS_S3_BUCKET"
@@ -74,7 +79,6 @@ locals {
7479
name = "CLOUDFLARE_AUTH_CLIENT_ID"
7580
value = data.sops_file.secret_vars.data["cloudflare_auth_client_id"]
7681
repositories = [
77-
"ansible-site-cluster",
7882
"images",
7983
"kustomize-cluster",
8084
"tfroot-github"
@@ -84,7 +88,6 @@ locals {
8488
name = "CLOUDFLARE_AUTH_CLIENT_SECRET"
8589
value = data.sops_file.secret_vars.data["cloudflare_auth_client_secret"]
8690
repositories = [
87-
"ansible-site-cluster",
8891
"images",
8992
"kustomize-cluster",
9093
"tfroot-github"
@@ -113,8 +116,6 @@ locals {
113116
name = "SOPS_AGE_KEY"
114117
value = data.sops_file.secret_vars.data["sops_age_key"]
115118
repositories = [
116-
"ansible-project-libvirt",
117-
"ansible-site-cluster",
118119
"tfroot-aws",
119120
"tfroot-cloudflare",
120121
"tfroot-github",
@@ -125,31 +126,15 @@ locals {
125126
name = "SSH_PRIVATE_KEY"
126127
value = data.sops_file.secret_vars.data["ssh_private_key"]
127128
repositories = [
128-
"ansible-site-cluster",
129129
"tfroot-libvirt"
130130
]
131131
}
132132
"ssh_known_hosts" = {
133133
name = "SSH_KNOWN_HOSTS"
134134
value = data.sops_file.secret_vars.data["ssh_known_hosts"]
135135
repositories = [
136-
"ansible-site-cluster",
137136
"tfroot-libvirt"
138137
]
139138
}
140-
"ssh_user" = {
141-
name = "SSH_USER"
142-
value = data.sops_file.secret_vars.data["ssh_user"]
143-
repositories = [
144-
"ansible-site-cluster"
145-
]
146-
}
147-
"ssh_host" = {
148-
name = "SSH_HOST"
149-
value = data.sops_file.secret_vars.data["ssh_host"]
150-
repositories = [
151-
"ansible-site-cluster"
152-
]
153-
}
154139
}
155140
}

0 commit comments

Comments
 (0)