This commit is contained in:
parent
81abb30846
commit
170c5e0730
@ -26,3 +26,5 @@ steps:
|
||||
- terraform init -backend-config="access_key=$ACCESS_KEY" -backend-config="secret_key=$SECRET_KEY"
|
||||
- terraform validate
|
||||
- terraform apply -auto-approve -var "hcloud_token=$HCLOUD_TOKEN" -var "pvt_key=../ssh_keys/id_ed25519" -var "pub_key=../ssh_keys/id_ed25519.pub" -var "hcloud_serverctl_ssh_key_id=$HCLOUD_SSH_KEY_ID"
|
||||
- cd ansible
|
||||
- ANSIBLE_HOST_KEY_CHECKING=False /usr/bin/ansible-playbook -u root --key-file '../../ssh_keys/id_ed25519' server-install.yml
|
||||
|
2
infrastructure/create-resources/ansible/inventory/hosts.cfg
Executable file
2
infrastructure/create-resources/ansible/inventory/hosts.cfg
Executable file
@ -0,0 +1,2 @@
|
||||
[serverctl_master_hosts]
|
||||
65.21.153.18
|
@ -1,6 +1,6 @@
|
||||
- become: yes
|
||||
hosts: all
|
||||
name: apache-install
|
||||
name: server-install
|
||||
tasks:
|
||||
- name: Add the user 'kjuulh' and add it to 'sudo'
|
||||
user:
|
||||
@ -14,22 +14,3 @@
|
||||
- name: Wait for apt to unlock
|
||||
become: yes
|
||||
shell: while sudo fuser /var/lib/dpkg/lock >/dev/null >2&1; do sleep 5; done;
|
||||
|
||||
- name: Install apache2
|
||||
apt:
|
||||
name: apache2
|
||||
update_cache: yes
|
||||
state: latest
|
||||
|
||||
- name: enable mod_rewrite
|
||||
apache2_module:
|
||||
name: rewrite
|
||||
state: present
|
||||
notify:
|
||||
- Restart apache2
|
||||
|
||||
handlers:
|
||||
- name: Restart apache2
|
||||
service:
|
||||
name: apache2
|
||||
state: restarted
|
@ -33,7 +33,7 @@ resource "null_resource" "configure_serverctl_master" {
|
||||
count = var.serverctl_master_count
|
||||
|
||||
provisioner "local-exec" {
|
||||
command = "ANSIBLE_HOST_KEY_CHECKING=False /usr/bin/ansible-playbook -u root -i '${element(hcloud_server.serverctl_master.*.ipv4_address, 0)},' --private-key ${var.pvt_key} -e 'pub_key=${var.pub_key}' apache-install.yml"
|
||||
command = "ANSIBLE_HOST_KEY_CHECKING=False /usr/bin/ansible-playbook -u root -i '${element(hcloud_server.serverctl_master.*.ipv4_address, 0)},' --private-key ${var.pvt_key} -e 'pub_key=${var.pub_key}' server-install.yml"
|
||||
}
|
||||
|
||||
triggers = {
|
||||
@ -47,3 +47,12 @@ output "master_ipv4_addresses" {
|
||||
serverctl.name => serverctl.ipv4_address
|
||||
}
|
||||
}
|
||||
|
||||
resource "local_file" "hosts_cfg" {
|
||||
content = templatefile("${path.module}/templates/hosts.tpl",
|
||||
{
|
||||
serverctl_masters = hcloud_server.serverctl_master.*.ipv4_address
|
||||
}
|
||||
)
|
||||
filename = "ansible/inventory/hosts.cfg"
|
||||
}
|
||||
|
@ -33,4 +33,3 @@ provider "hcloud" {
|
||||
variable "hcloud_serverctl_ssh_key_id" {}
|
||||
variable "pvt_key" {}
|
||||
variable "pub_key" {}
|
||||
|
||||
|
4
infrastructure/create-resources/templates/hosts.tpl
Normal file
4
infrastructure/create-resources/templates/hosts.tpl
Normal file
@ -0,0 +1,4 @@
|
||||
[serverctl_master_hosts]
|
||||
%{ for ip in serverctl_masters ~}
|
||||
${ip}
|
||||
%{ endfor ~}
|
Loading…
Reference in New Issue
Block a user