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

sync_plans role not idempotent #1804

Open
myllynen opened this issue Nov 28, 2024 · 5 comments
Open

sync_plans role not idempotent #1804

myllynen opened this issue Nov 28, 2024 · 5 comments

Comments

@myllynen
Copy link

This simple playbooks reports changed on every run (tested against Satellite 6.16):

---
- name: Configure Red Hat Satellite
  hosts: satellite
  become: true
  gather_facts: true
  vars:
    satellite_sync_plans:
      - name: Weekly Red Hat repository sync
        interval: weekly
        sync_date: 2022-01-01 02:02:00 UTC
        enabled: true
        products:
          - Red Hat Satellite Capsule
          - Red Hat Enterprise Linux for x86_64
  roles:
    - redhat.satellite.sync_plans

Since no passwords are involved here perhaps it would be possible to make this idempotent. Thanks.

@evgeni
Copy link
Member

evgeni commented Nov 28, 2024

Can you post the --diff output? I bet it's the way the date is stored (iirc that recently changed)

@myllynen
Copy link
Author

Here's the --diff output:

TASK [redhat.satellite.sync_plans : Create Sync Plans] ***************************************************************************************************************************************************************************************
Thursday 28 November 2024  17:17:33 +0200 (0:00:00.041)       0:00:00.041 ***** 
changed: [satellite.example.com] => (item={'name': 'Weekly Red Hat repository sync', 'interval': 'weekly', 'sync_date': '2022-01-01 02:02:00 UTC', 'enabled': True, 'products': ['Red Hat Satellite Capsule', 'Red Hat Enterprise Linux for x86_64']})

Here's also -v output just in case:

TASK [redhat.satellite.sync_plans : Create Sync Plans] ********************************************************************************************************************************************************************************[2/209]
Thursday 28 November 2024  17:18:26 +0200 (0:00:00.041)       0:00:00.041 *****                                                                                                                                                               
changed: [satellite.example.com] => (item={'name': 'Weekly Red Hat repository sync', 'interval': 'weekly', 'sync_date': '2022-01-01 02:02:00 UTC', 'enabled': True, 'products': ['Red Hat Satellite Capsule', 'Red Hat Enterprise Linux for x86_64']}) => 
    ansible_loop_var: item
    changed: true
    entity:
        sync_plans:
        -   created_at: 2024-11-27 16:40:59 UTC
            cron_expression: null
            description: null
            enabled: true
            foreman_tasks_recurring_logic_id: 10
            id: 1
            interval: weekly
            name: Weekly Red Hat repository sync
            next_sync: 2024-11-30 02:02:00 UTC
            organization_id: 1
            permissions:
                destroy_sync_plans: true
                edit_sync_plans: true
                view_sync_plans: true
            products:
            -   cp_id: '479'
                description: null
                id: 195
                label: Red_Hat_Enterprise_Linux_for_x86_64
                last_sync: null
                last_sync_words: null
                name: Red Hat Enterprise Linux for x86_64
                repository_count: 5
                sync_state: null
            -   cp_id: '269'
                description: null
                id: 274
                label: Red_Hat_Satellite_Capsule
                last_sync: null
                last_sync_words: null
                name: Red Hat Satellite Capsule
                repository_count: 1
                sync_state: null
            sync_date: 2022-01-01 02:02:00 +0000
            updated_at: 2024-11-27 16:40:59 UTC
        sync_plans/products:
        -   id: 1
            product_ids:
            - 274
            - 195
    item:
        enabled: true
        interval: weekly
        name: Weekly Red Hat repository sync
        products:
        - Red Hat Satellite Capsule
        - Red Hat Enterprise Linux for x86_64
        sync_date: 2022-01-01 02:02:00 UTC

@evgeni
Copy link
Member

evgeni commented Nov 28, 2024

Can you try using 2022-01-01 02:02:00 +0000 in your playbook?

@myllynen
Copy link
Author

Yes, that works, thanks!

@evgeni
Copy link
Member

evgeni commented Nov 28, 2024

Should this become "compare dates as dates, not strings"?
But at the same time: I don't think we'd get to it anytime soon

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

No branches or pull requests

2 participants