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

Conversation

simonfelding
Copy link

Description

Copying custom manifests didn't actually work with j2 templates.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Small minor change not affecting the Ansible Role code (GitHub Actions Workflow, Documentation etc.)

How Has This Been Tested?

executed the code and copied a file over

# 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
# 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.

# 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
# 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.

@@ -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

@@ -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

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)

@MonolithProjects MonolithProjects self-assigned this Oct 26, 2024
@MonolithProjects
Copy link
Collaborator

This was fixed in #290. Closing this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants