-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathspacewalk.yml
47 lines (46 loc) · 2.2 KB
/
spacewalk.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
#ansible-playbook -i spacewalk.py playbook.yml #https://groups.google.com/forum/#!msg/ansible-project/zjlUf1nKYls/Rj5I0354IQEJ
#http://www.it-hure.de/2013/07/thank-you-seth-vidal-my-first-ansible-playbook/
- hosts: new
user: root
sudo: no
vars:
# ansible_distribution: centos #workaround as it comes out as CentOS
key: 1-{{ ansible_distribution|lower + ansible_distribution_major_version }}-{{ ansible_architecture }}
ip: 192.168.0.105
fqdn: spacewalk.marafa.vm
spc_ver: 2.2-1 #pacewalk-client-repo version
rhnuser: administrator
rhnpw: password
tasks:
- name: Upgrade ca-certificates
yum: name=ca-certificates state=latest
- name: Install epel-repo
yum: name=epel-release state=latest
yum: pkg={{ item }} state=latest
when: ansible_os_family == 'RedHat'
with_items:
- epel-release
- libselinux-python
- selinux: state=disabled #modifies /etc/syconfig/selinux only
- name: Erase rhn-org-trusted-ssl-cert
yum: name=rhn-org-trusted-ssl-cert state=absent
- name: Add spacewalk FQDN to /etc/hosts
lineinfile: dest=/etc/hosts line="{{ ip }}\t{{ fqdn}}"
- name: Install spacewalk client repo
yum: name=http://{{ fqdn }}/pub/spacewalk-client-repo-{{ spc_ver }}.el6.noarch.rpm state=present
# yum: name=http://yum.spacewalkproject.org/2.2-client/RHEL/6/x86_64/spacewalk-client-repo-2.2-1.el6.noarch.rpm state=latest
- name: Install RHN support packages
yum: pkg={{ item }} state=installed
when: ansible_os_family == 'RedHat' and ansible_distribution_major_version|int >= 6
with_items:
- rhn-setup
- yum-rhn-plugin
- python-dmidecode
- yum-plugin-security.noarch
- python-hashlib
- name: Install spacewalk cert
yum: name=http://{{ fqdn }}/pub/rhn-org-trusted-ssl-cert-1.0-1.noarch.rpm state=present
- name: Configure up2date config file
lineinfile: dest=/etc/sysconfig/rhn/up2date regexp='sslCACert=/usr/share/rhn/RHNS-CA-CERT' line='sslCACert=/usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT'
lineinfile: dest=/etc/sysconfig/rhn/up2date regexp='serverURL=.$' line='https://{{ fqdn }}/XMLRPC'
- rhn_register: state=present activationkey={{ key }} server_url=https://{{ fqdn }}/XMLRPC username={{ rhnuser }} password={{ rhnpw }}