From 0cf37badcb26da8f6834c63f65ec34581d732cf5 Mon Sep 17 00:00:00 2001 From: Matteo Abis <1423701+Enucatl@users.noreply.github.com> Date: Tue, 17 Oct 2023 12:02:35 +0200 Subject: [PATCH] Add vars to add .ssh/config and /etc/hosts only optionally Fix #73 --- defaults/main.yml | 6 ++++++ tasks/hosts-add.yml | 2 ++ 2 files changed, 8 insertions(+) diff --git a/defaults/main.yml b/defaults/main.yml index a584721..694f69e 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -137,3 +137,9 @@ virt_infra_host_deps: virt_infra_guest_deps: - cloud-init - qemu-guest-agent + +# Automatically add entries to /etc/hosts on the kvmhost +virt_infra_add_etc_hosts: true + +# Automatically add entries to $HOME/.ssh/config on the kvmhost +virt_infra_add_ssh_config: true diff --git a/tasks/hosts-add.yml b/tasks/hosts-add.yml index 8a56e21..8ab930e 100644 --- a/tasks/hosts-add.yml +++ b/tasks/hosts-add.yml @@ -16,6 +16,7 @@ become: true delegate_to: "{{ kvmhost }}" when: + - virt_infra_add_etc_hosts - inventory_hostname not in groups['kvmhost'] - vm_ip is defined and vm_ip - virt_infra_state | default(virt_infra_state) == "running" @@ -46,6 +47,7 @@ become: false delegate_to: "{{ kvmhost }}" when: + - virt_infra_add_ssh_config - inventory_hostname not in groups['kvmhost'] - vm_ip is defined and vm_ip - virt_infra_state | default(virt_infra_state) == "running"