-
Notifications
You must be signed in to change notification settings - Fork 28
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
[ansible/ovos] Make sure directory exists priot backup #242
Conversation
WalkthroughThe changes involve enhancing the OVOS installer Ansible role by adding a pre-backup directory existence check. A new task uses the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
ansible/roles/ovos_installer/tasks/ovos.yml (1)
Line range hint
17-36
: Consider enhancing error handling and user feedbackWhile checking directory existence is a good practice, consider these improvements:
- Add debug output to list which directories are missing
- Consider making the backup behavior configurable (fail/skip/warn) when directories are missing
- Add a rescue block to handle potential archive module failures gracefully
Example implementation:
- name: Check backup directories ansible.builtin.stat: path: "{{ item }}" register: _ovos_installer_directory_exists loop: "{{ ovos_directories_backup }}" when: ovos_installer_cleaning | bool - name: List missing directories ansible.builtin.debug: msg: "Directory does not exist: {{ item.item }}" loop: "{{ _ovos_installer_directory_exists.results }}" when: - ovos_installer_cleaning | bool - not item.stat.exists
- name: Check if directory to backup exists | ||
ansible.builtin.stat: | ||
path: "{{ ovos_directories_backup }}" | ||
register: _ovos_installer_directory_exists | ||
when: ovos_installer_cleaning | bool | ||
tags: | ||
- uninstall | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix incorrect usage of ansible.builtin.stat with multiple paths
The ansible.builtin.stat
module expects a single path string, but ovos_directories_backup
is a list of paths. This will cause the task to fail.
Consider using a loop to check each directory separately:
- name: Check if directory to backup exists
ansible.builtin.stat:
- path: "{{ ovos_directories_backup }}"
+ path: "{{ item }}"
register: _ovos_installer_directory_exists
+ loop: "{{ ovos_directories_backup }}"
when: ovos_installer_cleaning | bool
tags:
- uninstall
Note: You'll need to adjust the backup task's condition to check the existence of all directories using the registered results.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
- name: Check if directory to backup exists | |
ansible.builtin.stat: | |
path: "{{ ovos_directories_backup }}" | |
register: _ovos_installer_directory_exists | |
when: ovos_installer_cleaning | bool | |
tags: | |
- uninstall | |
- name: Check if directory to backup exists | |
ansible.builtin.stat: | |
path: "{{ item }}" | |
register: _ovos_installer_directory_exists | |
loop: "{{ ovos_directories_backup }}" | |
when: ovos_installer_cleaning | bool | |
tags: | |
- uninstall |
Summary by CodeRabbit