-
Notifications
You must be signed in to change notification settings - Fork 7
/
rhel_register.yml
42 lines (36 loc) · 1.4 KB
/
rhel_register.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
- name: fail if no credentials are provided
fail:
msg: "Please define rhn_subscription_username, rhn_subscription_password and rhn_subscription_pool_id to enroll your system"
when: rhn_subscription_username is undefined or rhn_subscription_username|bool == false or
rhn_subscription_password is undefined or rhn_subscription_password|bool == false or
rhn_subscription_pool_id is undefine or rhn_subscription_password|bool == false
- name: Unsubscribe previous system
redhat_subscription:
state: absent
ignore_errors: true
become: true
- name: Cleanup previous systems
command: "subscription-manager remove --all"
changed_when: false
become: true
- name: Subscribe for RedHat systems
redhat_subscription:
state: present
username: "{{ rhn_subscription_username }}"
password: "{{ rhn_subscription_password }}"
pool: "{{ rhn_subscription_pool_id }}"
become: true
changed_when: false
- name: Attach to the desired pool
command: "subscription-manager attach --pool={{ rhn_subscription_pool_id }}"
become: true
changed_when: false
- name: Unsubscribe to previous repos
command: "subscription-manager repos --disable=*"
when: rhn_repos|length > 0
become: true
- name: Subscribe to the list of desired repos
command: "subscription-manager repos --enable {{ item }}"
with_items: "{{ rhn_repos }}"
when: rhn_repos|length > 0
become: true