Skip to content

Conversation

@ksobrenat32
Copy link
Member

@LuisDakan Try to make the PRs to main to avoid duplicated PRs ;)

Copilot AI review requested due to automatic review settings November 14, 2025 15:10
@ksobrenat32
Copy link
Member Author

@LuisDakan Try to check what was changed in comparison with main, if it looks ok, we can merge

PD: Don't forget to approve ;)

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR sets up infrastructure for mirroring Linux Mint repositories and ISO images on a LIDSoL mirror server. It introduces Ansible automation for deploying systemd services and timers that periodically synchronize content from upstream Linux Mint sources.

  • Adds Ansible playbook to deploy Linux Mint mirror synchronization services
  • Implements two separate sync scripts for repository packages and ISO images
  • Configures systemd timers to run synchronization every 15 minutes

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 20 comments.

Show a summary per file
File Description
mirrors/main.yml Main Ansible playbook entry point for mirror server setup
mirrors/hosts.ini Inventory file defining the target mirror server
mirrors/tasks/linux-mint.yaml Ansible tasks to deploy systemd services, timers, and sync scripts
mirrors/files/linux-mint/repository/scripts/linux-mint-sync-repo.sh Bash script to synchronize Linux Mint repository packages
mirrors/files/linux-mint/repository/confd/mintUpdateRepository.service Systemd service unit for repository synchronization
mirrors/files/linux-mint/repository/confd/mintUpdateRepository.timer Systemd timer to trigger repository sync every 15 minutes
mirrors/files/linux-mint/images/scripts/linux-mint-sync-images.sh Bash script to synchronize Linux Mint ISO images
mirrors/files/linux-mint/images/confd/mintUpdateImages.service Systemd service unit for ISO image synchronization
mirrors/files/linux-mint/images/confd/mintUpdateImages.timer Systemd timer to trigger image sync every 15 minutes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


function get_local_time() {
if [ -f ${MIRROR_DIRECTORY}/${LATEST_UPDATE_FILE} ]; then
cat ${MIRROR_DIRECTORY}/${LATEST_UPDATE_FILE} | head -n 1
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

Useless use of cat. Replace cat ${MIRROR_DIRECTORY}/${LATEST_UPDATE_FILE} | head -n 1 with head -n 1 ${MIRROR_DIRECTORY}/${LATEST_UPDATE_FILE} to avoid unnecessary process creation.

Suggested change
cat ${MIRROR_DIRECTORY}/${LATEST_UPDATE_FILE} | head -n 1
head -n 1 ${MIRROR_DIRECTORY}/${LATEST_UPDATE_FILE}

Copilot uses AI. Check for mistakes.
echo "Error: rsync failed"
exit 1
fi

Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

Remove trailing whitespace at the end of line.

Suggested change

Copilot uses AI. Check for mistakes.
| grep -Eo '[0-9]{2}-[A-Za-z]{3}-[0-9]{4} [0-9]{2}:[0-9]{2}')
local latest=""
local latest_epoch=0
#In case we don't receive any date for connection problems
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

Missing space after #. Should be # In case we don't receive any date for connection problems.

Suggested change
#In case we don't receive any date for connection problems
# In case we don't receive any date for connection problems

Copilot uses AI. Check for mistakes.

- name: Copy linux mint sync script for repository mirror
ansible.builtin.copy:
src: files/linux-mint/repository/scripts/linux-mint-sync-repo.sh
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

Extra space after src:. Remove the extra space for consistency with other file copy tasks in the playbook.

Suggested change
src: files/linux-mint/repository/scripts/linux-mint-sync-repo.sh
src: files/linux-mint/repository/scripts/linux-mint-sync-repo.sh

Copilot uses AI. Check for mistakes.
Type=oneshot
ExecStart=/usr/local/bin/linux-mint-sync-images.sh
TimeoutStartSec=7200
User=mirrors No newline at end of file
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

The service specifies User=mirrors, but there's no task in the Ansible playbook to create this user. Ensure the user exists on the target system, or add a task to create it before deploying these services.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

should I write the task in main instead?, because the user most exist for every mirror

MIRROR_DIRECTORY=/srv/linux-mint
LOCAL_MIRROR="lidsol.fi-b.unam.mx"
MIRROR_DIRECTORY_RP=${MIRROR_DIRECTORY}/repository
LATEST_UPDATE_FILE=latest_sync_repository.meta
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

The script creates directories and writes files in /srv/linux-mint while running as the mirrors user. Ensure the Ansible playbook creates the /srv/linux-mint directory with appropriate ownership and permissions for the mirrors user, otherwise the script will fail with permission errors.

Suggested change
LATEST_UPDATE_FILE=latest_sync_repository.meta
LATEST_UPDATE_FILE=latest_sync_repository.meta
# Ensure MIRROR_DIRECTORY exists and is writable
if [ ! -d "${MIRROR_DIRECTORY}" ]; then
mkdir -p "${MIRROR_DIRECTORY}" || { echo "Error: Could not create ${MIRROR_DIRECTORY}. Permission denied."; exit 1; }
fi
if [ ! -w "${MIRROR_DIRECTORY}" ]; then
echo "Error: ${MIRROR_DIRECTORY} is not writable by user $(whoami). Please ensure correct ownership and permissions."
exit 1
fi

Copilot uses AI. Check for mistakes.
LOCAL_MIRROR="lidsol.fi-b.unam.mx"
MIRROR_DIRECTORY_SO=${MIRROR_DIRECTORY}/images
LATEST_UPDATE_FILE=latest_sync_images.meta

Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

The script creates directories and writes files in /srv/linux-mint while running as the mirrors user. Ensure the Ansible playbook creates the /srv/linux-mint directory with appropriate ownership and permissions for the mirrors user, otherwise the script will fail with permission errors.

Suggested change
# Ensure the main mirror directory exists and is owned by the mirrors user
if [ ! -d "${MIRROR_DIRECTORY}" ]; then
mkdir -p "${MIRROR_DIRECTORY}"
fi
chown mirrors:mirrors "${MIRROR_DIRECTORY}"
chmod 755 "${MIRROR_DIRECTORY}"

Copilot uses AI. Check for mistakes.
echo "Error: rsync failed"
exit 1
fi

Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

Remove trailing whitespace at the end of line.

Suggested change

Copilot uses AI. Check for mistakes.
fi


if [ $(($current_time_epoch - $local_mirror_time_epoch)) -lt 43200 ]; then
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

The condition checks if less than 12 hours (43200 seconds) have passed, but the comment at the top of the file states "less than 24 hours". Either update this threshold to 86400 seconds to match the documentation, or update the file header comment to reflect the actual 12-hour threshold.

Suggested change
if [ $(($current_time_epoch - $local_mirror_time_epoch)) -lt 43200 ]; then
if [ $(($current_time_epoch - $local_mirror_time_epoch)) -lt 86400 ]; then

Copilot uses AI. Check for mistakes.

- name: Copy linux mint sync script for images mirror
ansible.builtin.copy:
src: files/linux-mint/images/scripts/linux-mint-sync-images.sh
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

Extra space after src:. Remove the extra space for consistency with other file copy tasks in the playbook.

Copilot uses AI. Check for mistakes.
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