improve ansible waiting times
This commit is contained in:
parent
b5ccfd973e
commit
e542ecc3a6
4 changed files with 34 additions and 18 deletions
|
@ -1,5 +1,5 @@
|
|||
#cloud-config
|
||||
hostname: dns
|
||||
hostname: hermes
|
||||
manage_etc_hosts: true
|
||||
ssh_pwauth: false
|
||||
disable_root: false
|
||||
|
@ -9,9 +9,3 @@ chpasswd:
|
|||
list: |
|
||||
root:root
|
||||
expire: False
|
||||
packages:
|
||||
- qemu-guest-agent
|
||||
- dnsmasq
|
||||
- dnsutils
|
||||
package_update: true
|
||||
package_upgrade: true
|
||||
|
|
|
@ -36,4 +36,4 @@ server=/pim.kunis.nl/192.168.30.3
|
|||
log-dhcp
|
||||
log-queries
|
||||
# Resolve dns.dmz to addresses on main NIC
|
||||
interface-name=dns.dmz,ens3
|
||||
interface-name=hermes.dmz,ens3
|
||||
|
|
|
@ -2,9 +2,21 @@
|
|||
- hosts: all
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- name: Wait for cloud init to finish
|
||||
pause:
|
||||
seconds: 120
|
||||
- name: Wait for host to come up
|
||||
wait_for:
|
||||
state: started
|
||||
port: 22
|
||||
host: "{{ internal_ip }}"
|
||||
delay: 10
|
||||
timeout: 300
|
||||
connect_timeout: 300
|
||||
search_regex: OpenSSH
|
||||
delegate_to: localhost
|
||||
- name: Wait for cloud-init to finish
|
||||
command:
|
||||
cmd: cloud-init status --wait
|
||||
- name: Gather facts
|
||||
setup:
|
||||
- name: Update repositories
|
||||
apt:
|
||||
autoremove: true
|
||||
|
@ -12,6 +24,12 @@
|
|||
state: latest
|
||||
update_cache: yes
|
||||
cache_valid_time: 86400 # One day
|
||||
- name: Install packages
|
||||
apt:
|
||||
pkg:
|
||||
- qemu-guest-agent
|
||||
- dnsmasq
|
||||
- dnsutils
|
||||
- name: Disable systemd-resolved
|
||||
systemd:
|
||||
name: systemd-resolved
|
16
main.tf
16
main.tf
|
@ -29,11 +29,11 @@ resource "libvirt_cloudinit_disk" "cloudinit" {
|
|||
name = "${var.name}.iso"
|
||||
pool = "init"
|
||||
user_data = templatefile("cloud_init.cfg.tftpl", { name = var.name, host_public_key = var.host_public_key })
|
||||
network_config = templatefile("network_config.cfg.tftpl", { internal_ip = var.internal_ip})
|
||||
network_config = templatefile("network_config.cfg.tftpl", { internal_ip = var.internal_ip })
|
||||
}
|
||||
|
||||
resource "libvirt_domain" "ubuntu" {
|
||||
name = var.name
|
||||
name = "hermes"
|
||||
memory = 1024
|
||||
vcpu = 4
|
||||
|
||||
|
@ -42,15 +42,19 @@ resource "libvirt_domain" "ubuntu" {
|
|||
}
|
||||
|
||||
network_interface {
|
||||
network_name = "dmzbr"
|
||||
hostname = "dns"
|
||||
addresses = ["${var.internal_ip}/24"]
|
||||
bridge = "dmzbr"
|
||||
hostname = "hermes"
|
||||
/* addresses = ["${var.internal_ip}/24"] */
|
||||
mac = "ca:fe:c0:ff:ee:07"
|
||||
}
|
||||
|
||||
cloudinit = libvirt_cloudinit_disk.cloudinit.id
|
||||
|
||||
provisioner "local-exec" {
|
||||
command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -T 60 -u root -i inventory ansible.yml"
|
||||
command = "ansible-playbook -e internal_ip=${var.internal_ip} -T 60 -u root -i inventory hermes.yml"
|
||||
|
||||
environment = {
|
||||
ANSIBLE_HOST_KEY_CHECKING = "False"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue