Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix copying custom manifests #265

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ rke2_disable_cloud_controller: false
# applicable only if rke2_disable_cloud_controller is true
rke2_cloud_provider_name: "external"

# Path to custom manifests deployed during the RKE2 installation
# It is possible to use Jinja2 templating in the manifests
# Path to folder with custom manifests deployed during the RKE2 installation
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thin't it's better to keep it as a list of manifests. They can be in different folders or subfolders

# It is possible to use Jinja2 templating in the manifests, if the filename ends with .j2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be also yaml or yml.

ansible.builtin.template will template file with any file extension. The .j2 is not mandatory. You may use just .yaml and the file will be still templated if there is a Jinja2 syntax in it.

This option was meant to be used for files with yaml (or yml) files. But user could use Jinja2 syntax in it and it would be templated.

The actual bug here is that if the user will add .j2 file extension to the manifest file, the file will end up with .j2 also on the RKE2 server.

rke2_custom_manifests:

# Path to static pods deployed during the RKE2 installation
Expand Down
4 changes: 2 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ rke2_disable_cloud_controller: false
# applicable only if rke2_disable_cloud_controller is true
rke2_cloud_provider_name: "external"

# Path to custom manifests deployed during the RKE2 installation
# It is possible to use Jinja2 templating in the manifests
# Path to folder with custom manifests deployed during the RKE2 installation
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thin't it's better to keep it as a list of manifests. They can be in different folders or subfolders

# It is possible to use Jinja2 templating in the manifests, if the filename ends with .j2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be also yaml or yml.

ansible.builtin.template will template file with any file extension. The .j2 is not mandatory. You may use just .yaml and the file will be still templated if there is a Jinja2 syntax in it.

This option was meant to be used for files with yaml (or yml) files. But user could use Jinja2 syntax in it and it would be templated.

The actual bug here is that if the user will add .j2 file extension to the manifest file, the file will end up with .j2 also on the RKE2 server.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, good point. Will fix.

rke2_custom_manifests:

# Path to static pods deployed during the RKE2 installation
Expand Down
10 changes: 5 additions & 5 deletions tasks/rke2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@
- name: Copy Custom Manifests
ansible.builtin.template:
src: "{{ item }}"
dest: "{{ rke2_data_path }}/server/manifests/"
dest: "{{ rke2_data_path }}/server/manifests/{{ item | basename | replace('.j2', '')}}"
owner: root
group: root
mode: 0644
with_items: "{{ rke2_custom_manifests }}"
mode: 0640
with_fileglob: "{{ rke2_custom_manifests }}/*"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thin't it's better to keep it as a list of manifests. They can be in different folders or subfolders

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I guess you could have {{ query('fileglob', rke2_custom_manifests + '/*') }} as an example instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, i think this is outdated

- name: Copy Custom Manifests
ansible.builtin.template:
src: "{{ item }}"
dest: "{{ rke2_data_path }}/server/manifests/{{ item | basename | regex_replace('\\.j2$', '') }}"
owner: root
group: root
mode: 0644
with_fileglob: "{{ rke2_custom_manifests }}/*"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, i think this is outdated

- name: Copy Custom Manifests
ansible.builtin.template:
src: "{{ item }}"
dest: "{{ rke2_data_path }}/server/manifests/{{ item | basename | regex_replace('\\.j2$', '') }}"
owner: root
group: root
mode: 0644
with_fileglob: "{{ rke2_custom_manifests }}/*"

Yep - with the same code I wrote! So now it includes the glob functionality that @MonolithProjects said he didn't want to implement. Was that on purpose?

Copy link
Collaborator

@MonolithProjects MonolithProjects Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No @simonfelding, i overlooked it. Seems like you included the code in #260 . Will check it tomorrow as it is probably breaking the Custom Manifests (#285)

when: rke2_custom_manifests

- name: Copy Static Pods
Expand All @@ -155,7 +155,7 @@
dest: "{{ rke2_data_path }}/agent/pod-manifests/"
owner: root
group: root
mode: 0644
mode: 0640
with_items: "{{ rke2_static_pods }}"
when: rke2_static_pods

Expand All @@ -165,5 +165,5 @@
dest: "/etc/default/rke2-{{ rke2_type }}"
owner: root
group: root
mode: 0644
mode: 0640
when: rke2_environment_options is defined and rke2_environment_options|length > 0