From d95ed460b09689761f7dd4d7ad7da31d7eb86565 Mon Sep 17 00:00:00 2001 From: Nitin Ravindran Date: Tue, 11 Aug 2020 17:25:36 -0400 Subject: [PATCH] allow multiple custom roles --- docs/book/src/capi/capi.md | 2 +- images/capi/ansible/haproxy.yml | 5 ++++- images/capi/ansible/node.yml | 5 ++++- images/capi/packer/config/ansible-args.json | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/book/src/capi/capi.md b/docs/book/src/capi/capi.md index 9f21e1e4e4..a163ca9931 100644 --- a/docs/book/src/capi/capi.md +++ b/docs/book/src/capi/capi.md @@ -45,7 +45,7 @@ Several variables can be used to customize the image build. | Variable | Description | Default | |----------|-------------|---------| | `custom_role` | If set to `"true"`, this will cause `image-builder` to run a custom Ansible role right before the `sysprep` role to allow for further customization. | `"false"` | -| `custom_role_name` | This must be set if `custom_role` is set to `"true"`, and is the name of the role to run. If the role is placed is in the `ansible/roles` directory, it can be referenced by name. Otherwise, it must be a fully qualified path to the role. | `""` | +| `custom_role_names` | This must be set if `custom_role` is set to `"true"`, and is the space delimited string of the roles to run. If the role is placed in the `ansible/roles` directory, it can be referenced by name. Otherwise, it must be a fully qualified path to the role. | `""` | | `disable_public_repos` | If set to `"true"`, this will disable all existing package repositories defined in the OS before doing any package installs. The `extra_repos` variable *must* be set for package installs to succeed. | `"false"` | | `extra_debs` | This can be set to a space delimited string containing the names of additional deb packages to install | `""` | | `extra_repos` | A space delimited string containing the names of files to add to the image containing repository definitions. The files should be given as absolute paths. | `""` | diff --git a/images/capi/ansible/haproxy.yml b/images/capi/ansible/haproxy.yml index 4e123c5c9d..b83f1eb9ad 100644 --- a/images/capi/ansible/haproxy.yml +++ b/images/capi/ansible/haproxy.yml @@ -23,7 +23,10 @@ - include_role: name: pki - include_role: - name: "{{ custom_role_name }}" + name: "{{ role }}" + loop: "{{ custom_role_names.split() }}" + loop_control: + loop_var: role when: custom_role | default(false)|bool - include_role: name: sysprep diff --git a/images/capi/ansible/node.yml b/images/capi/ansible/node.yml index 0a3e3b26c3..2f35d12896 100644 --- a/images/capi/ansible/node.yml +++ b/images/capi/ansible/node.yml @@ -25,7 +25,10 @@ - include_role: name: kubernetes - include_role: - name: "{{ custom_role_name }}" + name: "{{ role }}" + loop: "{{ custom_role_names.split() }}" + loop_control: + loop_var: role when: custom_role | default(false)|bool - include_role: name: sysprep diff --git a/images/capi/packer/config/ansible-args.json b/images/capi/packer/config/ansible-args.json index b07cb40056..a541f0afd2 100644 --- a/images/capi/packer/config/ansible-args.json +++ b/images/capi/packer/config/ansible-args.json @@ -1,3 +1,3 @@ { - "ansible_common_vars": "containerd_url={{user `containerd_url`}} containerd_sha256={{user `containerd_sha256`}} containerd_pause_image={{user `containerd_pause_image`}} containerd_additional_settings={{user `containerd_additional_settings`}} custom_role={{user `custom_role`}} custom_role_name={{user `custom_role_name`}} disable_public_repos={{user `disable_public_repos`}} extra_debs={{user `extra_debs`}} extra_repos={{user `extra_repos`}} extra_rpms={{user `extra_rpms`}} http_proxy={{user `http_proxy`}} https_proxy={{user `https_proxy`}} kubeadm_template={{user `kubeadm_template`}} kubernetes_cni_http_source={{user `kubernetes_cni_http_source`}} kubernetes_cni_http_checksum={{user `kubernetes_cni_http_checksum`}} kubernetes_http_source={{user `kubernetes_http_source`}} kubernetes_container_registry={{user `kubernetes_container_registry`}} kubernetes_rpm_repo={{user `kubernetes_rpm_repo`}} kubernetes_rpm_gpg_key={{user `kubernetes_rpm_gpg_key`}} kubernetes_rpm_gpg_check={{user `kubernetes_rpm_gpg_check`}} kubernetes_deb_repo={{user `kubernetes_deb_repo`}} kubernetes_deb_gpg_key={{user `kubernetes_deb_gpg_key`}} kubernetes_cni_deb_version={{user `kubernetes_cni_deb_version`}} kubernetes_cni_rpm_version={{user `kubernetes_cni_rpm_version`}} kubernetes_cni_semver={{user `kubernetes_cni_semver`}} kubernetes_cni_source_type={{user `kubernetes_cni_source_type`}} kubernetes_semver={{user `kubernetes_semver`}} kubernetes_source_type={{user `kubernetes_source_type`}} kubernetes_load_additional_imgs={{user `kubernetes_load_additional_imgs`}} kubernetes_deb_version={{user `kubernetes_deb_version`}} kubernetes_rpm_version={{user `kubernetes_rpm_version`}} no_proxy={{user `no_proxy`}} redhat_epel_rpm={{user `redhat_epel_rpm`}} reenable_public_repos={{user `reenable_public_repos`}} remove_extra_repos={{user `remove_extra_repos`}} " + "ansible_common_vars": "containerd_url={{user `containerd_url`}} containerd_sha256={{user `containerd_sha256`}} containerd_pause_image={{user `containerd_pause_image`}} containerd_additional_settings={{user `containerd_additional_settings`}} custom_role={{user `custom_role`}} custom_role_names={{user `custom_role_names`}} disable_public_repos={{user `disable_public_repos`}} extra_debs={{user `extra_debs`}} extra_repos={{user `extra_repos`}} extra_rpms={{user `extra_rpms`}} http_proxy={{user `http_proxy`}} https_proxy={{user `https_proxy`}} kubeadm_template={{user `kubeadm_template`}} kubernetes_cni_http_source={{user `kubernetes_cni_http_source`}} kubernetes_cni_http_checksum={{user `kubernetes_cni_http_checksum`}} kubernetes_http_source={{user `kubernetes_http_source`}} kubernetes_container_registry={{user `kubernetes_container_registry`}} kubernetes_rpm_repo={{user `kubernetes_rpm_repo`}} kubernetes_rpm_gpg_key={{user `kubernetes_rpm_gpg_key`}} kubernetes_rpm_gpg_check={{user `kubernetes_rpm_gpg_check`}} kubernetes_deb_repo={{user `kubernetes_deb_repo`}} kubernetes_deb_gpg_key={{user `kubernetes_deb_gpg_key`}} kubernetes_cni_deb_version={{user `kubernetes_cni_deb_version`}} kubernetes_cni_rpm_version={{user `kubernetes_cni_rpm_version`}} kubernetes_cni_semver={{user `kubernetes_cni_semver`}} kubernetes_cni_source_type={{user `kubernetes_cni_source_type`}} kubernetes_semver={{user `kubernetes_semver`}} kubernetes_source_type={{user `kubernetes_source_type`}} kubernetes_load_additional_imgs={{user `kubernetes_load_additional_imgs`}} kubernetes_deb_version={{user `kubernetes_deb_version`}} kubernetes_rpm_version={{user `kubernetes_rpm_version`}} no_proxy={{user `no_proxy`}} redhat_epel_rpm={{user `redhat_epel_rpm`}} reenable_public_repos={{user `reenable_public_repos`}} remove_extra_repos={{user `remove_extra_repos`}} " }