forked from t-prinz/redhat_satellite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
satellite_update_cv_errata.yml
90 lines (78 loc) · 3.72 KB
/
satellite_update_cv_errata.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
---
- name: Update a Content View with all errata up to a specified date and publish to a set of environments
gather_facts: false
hosts: "{{ hostlist | default('all') }}"
vars:
satellite_exclude_start_date: ""
satellite_content_view: ""
satellite_target_lifecycle_environments:
- Library
- Dev
- Test
tasks:
- name: Run this on localhost but pickup the host_vars associated with the specified inventory_hostname
delegate_to: localhost
block:
- name: Error out if the Content View is not specified
ansible.builtin.assert:
fail_msg: "The Content View must be specified"
that:
- satellite_content_view | length > 0
- name: Block to handle case where satellite_exclude_start_date is not specified
when: satellite_exclude_start_date | length == 0
block:
- name: Gather facts
ansible.builtin.gather_facts:
- name: Print current date information if exclude start date is not specified
ansible.builtin.debug:
msg: "Exclude start date not specified; current date of {{ ansible_date_time.date }} will be used"
- name: Set the filter filter_start_date
ansible.builtin.set_fact:
filter_start_date: "{{ ansible_date_time.date if (satellite_exclude_start_date | length == 0) else satellite_exclude_start_date }}"
- name: Print exclude filter start date
ansible.builtin.debug:
msg: "Errata after {{ filter_start_date }} will be excluded"
- name: Ensure the Satellite server name is defined
ansible.builtin.set_fact:
satellite_server_url: "https://{{ ansible_host }}"
- name: Print Satellite server connection information
ansible.builtin.debug:
msg: "Configuring Satellite server at {{ satellite_server_url }}"
- name: Define variable
ansible.builtin.set_fact:
satellite_content_views_to_publish:
- organization: "{{ satellite_organization }}"
password: "{{ satellite_password }}"
server_url: "{{ satellite_server_url }}"
username: "{{ satellite_username }}"
validate_certs: "{{ satellite_validate_certs }}"
content_view: "{{ satellite_content_view }}"
description: "All packages, errata excluded starting {{ filter_start_date }}"
force_promote: true
lifecycle_environments: "{{ satellite_target_lifecycle_environments }}"
state: present
# version: "{{ filter_start_date }}"
# version: "4.0"
content_view_filters:
- date_type: updated
description: Exclude errata after a given date
filter_state: present
filter_type: erratum
inclusion: false
name: Errata-To-Date
rule_state: present
start_date: "{{ filter_start_date }}"
types:
- bugfix
- enhancement
- security
- name: Print Content View information
ansible.builtin.debug:
var: item
loop: "{{ satellite_content_views_to_publish }}"
when: satellite_content_views_to_publish is defined
- name: Loop over all the content views/filter definitions and ensure they are created and published
ansible.builtin.include_tasks:
file: files/content_view_loop_tasks.yml
loop: "{{ satellite_content_views_to_publish }}"
when: satellite_content_views_to_publish is defined