From a52bb767dd9e9b61394d1ade6095a696e6f2f77a Mon Sep 17 00:00:00 2001 From: Timo Makinen Date: Fri, 11 Sep 2020 15:27:05 +0000 Subject: [PATCH] Add support for installing CentOS with static IP address --- group_vars/centos7.yml | 10 +++++++++- group_vars/centos8.yml | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/group_vars/centos7.yml b/group_vars/centos7.yml index faf0ef5..e870f24 100644 --- a/group_vars/centos7.yml +++ b/group_vars/centos7.yml @@ -6,6 +6,14 @@ num_cpus: 1 # extra args for virt-install ks_file: "{{ boot_url }}/centos7.ks" +ipcmd: >- + {% if network_interfaces[0]['proto'] is defined %} + {% if network_interfaces[0]['proto'] == 'static' %} + {% set int=network_interfaces[0] %} + nameserver=8.8.8.8 + ip={{ int['ipaddr'] }}::{{ network_default_gateway }}:{{ int['netmask'] }}:::none + {% endif %} + {% endif %} virt_install_os_args: > - --extra-args "ks={{ ks_file }} console=ttyS0 net.ifnames=0 ksdevice=eth0" + --extra-args "ks={{ ks_file }} console=ttyS0 net.ifnames=0 ksdevice=eth0 {{ ipcmd }}" --location https://nic.funet.fi/pub/mirrors/centos.org/7/os/x86_64 diff --git a/group_vars/centos8.yml b/group_vars/centos8.yml index 7eaa37c..3c4da8f 100644 --- a/group_vars/centos8.yml +++ b/group_vars/centos8.yml @@ -6,6 +6,14 @@ num_cpus: 1 # extra args for virt-install ks_file: "{{ boot_url }}/centos8.ks" +ipcmd: >- + {% if network_interfaces[0]['proto'] is defined %} + {% if network_interfaces[0]['proto'] == 'static' %} + {% set int=network_interfaces[0] %} + nameserver=8.8.8.8 + ip={{ int['ipaddr'] }}::{{ network_default_gateway }}:{{ int['netmask'] }}:::none + {% endif %} + {% endif %} virt_install_os_args: > - --extra-args "ks={{ ks_file }} console=ttyS0 net.ifnames=0 ksdevice=eth0" --location https://nic.funet.fi/pub/mirrors/centos.org/8/BaseOS/x86_64/os + --extra-args "ks={{ ks_file }} console=ttyS0 net.ifnames=0 ksdevice=eth0 {{ ipcmd }}"