From b66c740799b6bbdd868be53e2589a5b458150aa6 Mon Sep 17 00:00:00 2001 From: Dirane TAFEN Date: Tue, 20 Feb 2018 11:44:49 +0000 Subject: [PATCH] Add disable cloud-init support --- ansible/disable-cloud-init.yml | 12 ++++++++++++ ansible/group_vars/all/overcloud | 3 +++ ansible/roles/disable-cloud-init/handlers/main.yml | 7 +++++++ ansible/roles/disable-cloud-init/tasks/main.yml | 9 +++++++++ etc/kayobe/overcloud.yml | 3 +++ kayobe/cli/commands.py | 2 +- kayobe/tests/unit/cli/test_commands.py | 1 + 7 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 ansible/disable-cloud-init.yml create mode 100644 ansible/roles/disable-cloud-init/handlers/main.yml create mode 100644 ansible/roles/disable-cloud-init/tasks/main.yml diff --git a/ansible/disable-cloud-init.yml b/ansible/disable-cloud-init.yml new file mode 100644 index 000000000..222f3bf1d --- /dev/null +++ b/ansible/disable-cloud-init.yml @@ -0,0 +1,12 @@ +--- +# Cloud-init ‘s searches for network configuration in order of +# increasing precedence; each item overriding the previous. +# In some cases cloud-init reconfigure automatically network interface +# and cause some issues in network configuration +- name: Disable Cloud-init service + hosts: overcloud + tags: + - disable-cloud-init + roles: + - role: disable-cloud-init + when: disable_cloud_init | bool diff --git a/ansible/group_vars/all/overcloud b/ansible/group_vars/all/overcloud index 5c3cff206..c374a6ff1 100644 --- a/ansible/group_vars/all/overcloud +++ b/ansible/group_vars/all/overcloud @@ -16,6 +16,9 @@ overcloud_groups: > # should not be added to the inventory. overcloud_group_hosts_map: {} +# To prevent some network issues you can choose to disable cloud-init +disable_cloud_init: False + ############################################################################### # Overcloud host image configuration. diff --git a/ansible/roles/disable-cloud-init/handlers/main.yml b/ansible/roles/disable-cloud-init/handlers/main.yml new file mode 100644 index 000000000..3fc34e8ea --- /dev/null +++ b/ansible/roles/disable-cloud-init/handlers/main.yml @@ -0,0 +1,7 @@ +--- +- name: restart cloud-init daemon + systemd: + name: cloud-init + state: restarted + daemon_reload: yes + become: True diff --git a/ansible/roles/disable-cloud-init/tasks/main.yml b/ansible/roles/disable-cloud-init/tasks/main.yml new file mode 100644 index 000000000..89c23f198 --- /dev/null +++ b/ansible/roles/disable-cloud-init/tasks/main.yml @@ -0,0 +1,9 @@ +--- +- name: Disable cloud init service + file: + path: /etc/cloud/cloud-init.disabled + state: touch + mode: "u=rw,g=r,o=r" + notify: + - restart cloud-init daemon + become: True diff --git a/etc/kayobe/overcloud.yml b/etc/kayobe/overcloud.yml index 4b35737a7..24ac59e69 100644 --- a/etc/kayobe/overcloud.yml +++ b/etc/kayobe/overcloud.yml @@ -13,6 +13,9 @@ # should not be added to the inventory. #overcloud_group_hosts_map: +# To prevent some network issues you can choose to disable cloud-init +disable_cloud_init: False + ############################################################################### # Overcloud host image configuration. diff --git a/kayobe/cli/commands.py b/kayobe/cli/commands.py index fb281147f..6b011f32f 100644 --- a/kayobe/cli/commands.py +++ b/kayobe/cli/commands.py @@ -691,7 +691,7 @@ class OvercloudHostConfigure(KollaAnsibleMixin, KayobeAnsibleMixin, VaultMixin, playbooks += _build_playbook_list("wipe-disks") playbooks += _build_playbook_list( "users", "yum", "dev-tools", "disable-selinux", "network", - "sysctl", "disable-glean", "ntp", "lvm") + "sysctl", "disable-glean", "disable-cloud-init", "ntp", "lvm") self.run_kayobe_playbooks(parsed_args, playbooks, limit="overcloud") playbooks = _build_playbook_list("kolla-ansible") self.run_kayobe_playbooks(parsed_args, playbooks, tags="config") diff --git a/kayobe/tests/unit/cli/test_commands.py b/kayobe/tests/unit/cli/test_commands.py index 84aa64e1d..6d2abf4e1 100644 --- a/kayobe/tests/unit/cli/test_commands.py +++ b/kayobe/tests/unit/cli/test_commands.py @@ -466,6 +466,7 @@ class TestCase(unittest.TestCase): "ansible/network.yml", "ansible/sysctl.yml", "ansible/disable-glean.yml", + "ansible/disable-cloud-init.yml", "ansible/ntp.yml", "ansible/lvm.yml", ],