@@ -43,80 +43,3 @@ resource "github_branch_protection" "main" {
43
43
contexts = [" validate" ]
44
44
}
45
45
}
46
-
47
- /* *
48
- * Github environnement secrets for Ansible
49
- *
50
- */
51
- resource "github_actions_environment_secret" "inventory" {
52
- repository = data. github_repository . repo . name
53
- environment = github_repository_environment. digitalocean_environment . environment
54
- secret_name = " inventory"
55
- plaintext_value = templatefile (
56
- " ${ path . module } /templates/ansible_inventory.tpl" ,
57
- {
58
- user = " root"
59
- prefix = " swarm"
60
- nodes = digitalocean_droplet.nodes.* .ipv4_address,
61
- managers = digitalocean_droplet.managers.* .ipv4_address
62
- }
63
- )
64
- }
65
-
66
- resource "github_actions_environment_secret" "ssh" {
67
- repository = data. github_repository . repo . name
68
- environment = github_repository_environment. digitalocean_environment . environment
69
- secret_name = " ssh_key"
70
- plaintext_value = tls_private_key. ssh . private_key_pem
71
- }
72
-
73
- data "sshclient_host" "nodes" {
74
- count = length (digitalocean_droplet. nodes )
75
- hostname = digitalocean_droplet. nodes [count . index ]. ipv4_address
76
- username = " keyscan"
77
- insecure_ignore_host_key = true # we use this to scan and obtain the key
78
- }
79
-
80
- data "sshclient_host" "managers" {
81
- count = length (digitalocean_droplet. managers )
82
- hostname = digitalocean_droplet. managers [count . index ]. ipv4_address
83
- username = " keyscan"
84
- insecure_ignore_host_key = true # we use this to scan and obtain the key
85
- }
86
-
87
- resource "time_sleep" "wait_30_seconds" {
88
- depends_on = [digitalocean_droplet . nodes , digitalocean_droplet . managers ]
89
-
90
- create_duration = " 30s"
91
- }
92
-
93
- data "sshclient_keyscan" "keyscan_nodes" {
94
- count = length (data. sshclient_host . nodes )
95
- host_json = data. sshclient_host . nodes [count . index ]. json
96
- depends_on = [time_sleep . wait_30_seconds ]
97
- }
98
-
99
- data "sshclient_keyscan" "keyscan_managers" {
100
- count = length (data. sshclient_host . managers )
101
- host_json = data. sshclient_host . managers [count . index ]. json
102
- depends_on = [time_sleep . wait_30_seconds ]
103
- }
104
-
105
- locals {
106
- known_hosts = merge (
107
- {for k , v in data . sshclient_host . nodes : v . hostname => data . sshclient_keyscan . keyscan_nodes [k ]. authorized_key },
108
- {for k , v in data . sshclient_host . managers : v . hostname => data . sshclient_keyscan . keyscan_managers [k ]. authorized_key },
109
- )
110
- }
111
-
112
- resource "github_actions_environment_secret" "known_hosts" {
113
- repository = data. github_repository . repo . name
114
- environment = github_repository_environment. digitalocean_environment . environment
115
- secret_name = " known_hosts"
116
- plaintext_value = templatefile (
117
- " ${ path . module } /templates/known_hosts.tpl" ,
118
- {
119
- known_hosts = local.known_hosts
120
- }
121
- )
122
- }
0 commit comments