Skip to content
This repository has been archived by the owner on Apr 15, 2023. It is now read-only.

Commit

Permalink
Merge pull request #24 from stdevel/feat-sp2-23
Browse files Browse the repository at this point in the history
Add support for Uyuni 2020.07 / openSUSE Leap 15.2 and SUSE Manager 4.1 / SLE 15 SP2
  • Loading branch information
stdevel committed Sep 23, 2020
2 parents d555c5a + 3caf6c5 commit 1a2af80
Show file tree
Hide file tree
Showing 20 changed files with 119 additions and 68 deletions.
2 changes: 2 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
skip_list:
- '303'
4 changes: 4 additions & 0 deletions .markdownlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
"MD013": false # line-length
"MD014": false # show commands output
"MD041": false # first line should be heading (build status image)
3 changes: 3 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
rules:
line-length: disable
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The system needs access to the internet. Also, you will need an openSUSE Leap or

| Variable | Default | Description |
| -------- | ------- | ----------- |
| `suma_release` | `4.1` | SUSE Manager release to install (*4.0 or 4.1*) |
| `scc_reg_code` | - | [SUSE Customer Center](https://scc.suse.com) registration code (*received after trial registration or purchase*) |
| `scc_mail` | - | SUSE Customer Center mail address |
| `scc_check_registration` | `true` | Register system if unregistered |
Expand Down Expand Up @@ -107,6 +108,19 @@ Don't forget setting SUSE-related variables when deploying SUSE Manager:
scc_mail: bla@foo.bar
```

Ensure having all available system updates installed **before** running the playbook!

## Common issues

Error when running the playbook:

```shell
TASK [ansible-uyuni : Add Uyuni repository] ************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named xml.dom.minidom
```

Install the missing `python-xml` package.

## License

Apache 2.0
Expand Down
19 changes: 13 additions & 6 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,26 @@ uyuni_repo: "https://download.opensuse.org/repositories/systemsmanagement:/Uyuni
uyuni_packages:
- spacewalk-utils
- spacecmd
suma_release: 4.1
scc_check_registration: true
scc_check_modules: true
# The 'Desktop Applications' and 'Development Tools'
# modules are required for CEFS/DEFS!
sles_modules:
- name: sle-module-basesystem
identifier: sle-module-basesystem/15.1/x86_64
identifier: "sle-module-basesystem/{{ ansible_distribution_version }}/x86_64"
- name: sle-module-python2
identifier: sle-module-python2/15.1/x86_64
- name: sle-module-suse-manager-server
identifier: sle-module-suse-manager-server/4.0/x86_64
identifier: "sle-module-python2/{{ ansible_distribution_version }}/x86_64"
- name: sle-module-server-applications
identifier: sle-module-server-applications/15.1/x86_64
identifier: "sle-module-server-applications/{{ ansible_distribution_version }}/x86_64"
- name: sle-module-web-scripting
identifier: sle-module-web-scripting/15.1/x86_64
identifier: "sle-module-web-scripting/{{ ansible_distribution_version }}/x86_64"
- name: sle-module-desktop-applications
identifier: "sle-module-desktop-applications/{{ ansible_distribution_version }}/x86_64"
- name: sle-module-development-tools
identifier: "sle-module-development-tools/{{ ansible_distribution_version }}/x86_64"
- name: sle-module-suse-manager-server
identifier: "sle-module-suse-manager-server/{{ suma_release }}/x86_64"

# storage configuration
use_lvm: true
Expand Down
2 changes: 1 addition & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ galaxy_info:
platforms:
- name: opensuse
versions:
- 15.1
- 15.2
- name: sles
versions:
- 15
Expand Down
50 changes: 41 additions & 9 deletions molecule/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# molecule

This folder contains molecule configuration and tests.

## Preparation

Ensure to the following installed:

- [Vagrant](https://vagrantup.com)
- [Oracle VirtualBox](https://virtualbox.org)
- Python modules
Expand All @@ -11,17 +14,21 @@ Ensure to the following installed:
- [`python-vagrant`](https://pypi.org/project/python-vagrant/)

## Environment

The test environment consists of two test scenarios:
- `default` - default scenario with VM running openSUSE Leap 15.1
- `suma` - SUSE Manager 4.x scenario with VM running SUSE Linux Enterprise Server 15 SP1

- `default` - default scenario with VM running openSUSE Leap 15.2
- `suma` - SUSE Manager 4.x scenario with VM running SUSE Linux Enterprise Server 15 SP1 or SP2

### SUSE hints
In order to run tests against SUSE Linux Enterprise Server 15 SP1 / SUSE Manager 4.x you will either require a valid subscription or a trial license.

In order to run tests against SUSE Manager 4.x you will either require a valid subscription or a trial license.
You can request a [60-day trial on the SUSE website.](https://www.suse.com/products/suse-manager/download/)
For this, you will need to create a [SUSE Customer Center](https://scc.suse.com) account - you will **not** be able to request an additional trial for the same release after the 60 days have expired.

When using SLES, alter ``suma/converge.yml`` like this:
```

```yml
---
- name: Converge machines
hosts: all
Expand All @@ -34,23 +41,46 @@ When using SLES, alter ``suma/converge.yml`` like this:

Also, you will need a SLES Vagrant box. As the [SUSE End-user license agreement](https://www.suse.com/licensing/eula/download/sles/sles15sp1-en-us.pdf) for SLES 15 SP1 does not allow re-distributing binary releases, I'm unable to provide you a Vagrant box.
You might want to have a look at these sites in order to find out how to create SLE 15 Vagrant boxes:
- https://github.com/lavabit/robox
- https://github.com/chef/bento/tree/master/packer_templates/sles

- [https://github.com/lavabit/robox](https://github.com/lavabit/robox)
- [https://github.com/chef/bento/tree/master/packer_templates/sles](https://github.com/chef/bento/tree/master/packer_templates/sles)

Beginning with SLE 15 SP2, SUSE ships Vagrantboxes again. To import it, use the following command:

```shell
$ vagrant box add sles15-sp2 SLES15-SP2-Vagrant.x86_64-15.2-<provider>-GM.vagrant.<provider>.box
```

Replace `<provider>` with `virtualbox` or `libvirt`.

## Usage

In order to create the test environment execute the following command:

```
```shell
$ molecule create
```

Run the Ansible role:
**Double-check** the VM settings! Sometimes Molecule doesn't change the CPU count and memory size. The result is a crashing installation.

Also ensure that all available updates have been installed

```shell
$ molecule login --host opensuse-leap15
$ sudo zypper update -y ; exit
$ molecule login --host suma4
$ sudo zypper update -y ; exit
```

Run the Ansible role:

```shell
$ molecule converge
```

Finally, run the tests:
```

```shell
$ molecule verify
...
collected 8 items
Expand All @@ -62,3 +92,5 @@ Verifier completed successfully.
```

For running tests in the `suma` scenario context, run the commands above with the `-s suma` parameter.

When creating your own Vagrantbox, you will need to edit `suma/molecule/molecule.yml` and change the name.
1 change: 1 addition & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
hosts: all
roles:
- role: ansible-uyuni
use_lvm: false
config_firewall: false
setup_cefs: true
setup_cefs_cronjob: true
Expand Down
9 changes: 2 additions & 7 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,16 @@ dependency:
name: galaxy
driver:
name: vagrant
provider:
name: virtualbox
lint: |
yamllint .
ansible-lint
flake8
platforms:
- name: opensuse-leap151
- name: opensuse-leap15
box: generic/opensuse15
box_version: "3.0.10"
box_version: "3.0.22"
cpus: 2
memory: 4096
provider_raw_config_args:
- "customize ['createhd', '--filename', 'uyuni01.vdi', '--size', 50 * 1024]"
- "customize ['storageattach', :id, '--storagectl', 'IDE Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', 'uyuni01.vdi']"
provisioner:
name: ansible
verifier:
Expand Down
13 changes: 1 addition & 12 deletions molecule/default/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,7 @@ uyuni_packages:
- spacecmd

# storage configuration
use_lvm: true
vg_uyuni: vg_uyuni
pv_uyuni: /dev/sdb
filesystems:
- name: lv_spacewalk
type: xfs
mountpoint: /var/spacewalk
size: 10240
- name: lv_pgsql
type: xfs
mountpoint: /var/lib/pgsql
size: 10240
use_lvm: false

# Uyuni configuration
org_name: "Demo"
Expand Down
5 changes: 3 additions & 2 deletions molecule/suma/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
hosts: all
roles:
- role: ansible-uyuni
scc_reg_code: <insert code here>
scc_mail: <insert SCC mail here>
use_lvm: false
scc_reg_code: "<insert code here>"
scc_mail: "<insert SCC mail here>"
config_firewall: false
setup_cefs: true
setup_cefs_cronjob: true
Expand Down
7 changes: 1 addition & 6 deletions molecule/suma/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,15 @@ dependency:
name: galaxy
driver:
name: vagrant
provider:
name: virtualbox
lint: |
yamllint .
ansible-lint
flake8
platforms:
- name: suma4
box: suma4
box: sles15-sp2-GM
cpus: 2
memory: 4096
provider_raw_config_args:
- "customize ['createhd', '--filename', 'uyuni02.vdi', '--size', 50 * 1024]"
- "customize ['storageattach', :id, '--storagectl', 'SATA', '--port', 2, '--device', 0, '--type', 'hdd', '--medium', 'uyuni02.vdi']"
provisioner:
name: ansible
verifier:
Expand Down
13 changes: 1 addition & 12 deletions molecule/suma/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,7 @@ uyuni_packages:
- spacecmd

# storage configuration
use_lvm: true
vg_uyuni: vg_uyuni
pv_uyuni: /dev/sdb
filesystems:
- name: lv_spacewalk
type: xfs
mountpoint: /var/spacewalk
size: 10240
- name: lv_pgsql
type: xfs
mountpoint: /var/lib/pgsql
size: 10240
use_lvm: false

# Uyuni configuration
org_name: "Demo"
Expand Down
4 changes: 0 additions & 4 deletions tasks/check.yml

This file was deleted.

4 changes: 4 additions & 0 deletions tasks/check_opensuse_leap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
- name: Ensure having 15 SP2 release
fail: msg="Please upgrade to SP2"
when: "ansible_distribution_version != '15.2'"
12 changes: 12 additions & 0 deletions tasks/check_sles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
- name: Ensure having supported SP release for SUMA 4.0
fail: msg="Please upgrade to SP1"
when:
- suma_release == 4.0
- ansible_distribution_version != '15.1'

- name: Ensure having supported SP release for SUMA 4.1
fail: msg="Please upgrade to SP2"
when:
- suma_release == 4.1
- ansible_distribution_version != '15.2'
2 changes: 1 addition & 1 deletion tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
url: https://localhost/rhn/newlogin/CreateFirstUser.do
method: POST
validate_certs: false
body: "submitted=true&orgName={{ org_name }}&login={{ org_login }}&desiredpassword={{ org_password }}&desiredpasswordConfirm={{ org_password }}&email={{ org_mail }}&firstNames={{ org_first_name }}&lastName={{ org_last_name }}"
body: "submitted=true&orgName={{ org_name }}&login={{ org_login }}&desiredpassword={{ org_password }}&desiredpasswordConfirm={{ org_password }}&email={{ org_mail }}&firstNames={{ org_first_name }}&lastName={{ org_last_name }}" # noqa: 204
body_format: "form-urlencoded"
status_code:
- 201
Expand Down
2 changes: 1 addition & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: Include variables
include_vars: "{{ ansible_distribution | regex_replace(' ', '_') | lower }}.yml"

- include_tasks: "check.yml"
- include_tasks: "check_{{ ansible_distribution | regex_replace(' ', '_') | lower }}.yml"
tags: prepare

- include_tasks: "prepare_{{ ansible_distribution | regex_replace(' ', '_') | lower }}.yml"
Expand Down
6 changes: 0 additions & 6 deletions tasks/prepare.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
---
- name: Update system
zypper:
name: "*"
state: latest
become: true

- name: Install core utilities
zypper:
name: "{{ core_packages }}"
Expand Down
15 changes: 14 additions & 1 deletion tasks/prepare_sles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,21 @@
when: scc_check_registration or scc_check_modules
become: true

- name: Prepare JeOS
block:
- name: Remove SLES release
command: 'rpm -e --nodeps sles-release'
args:
removes: /etc/products.d/SLES.prod
- name: Alter zypp configuration
lineinfile:
path: /etc/zypp/zypp.conf
regexp: '^solver.onlyRequires'
line: 'solver.onlyRequires = false'
become: true

- name: Register system
command: "SUSEConnect -r {{ scc_reg_code }} -e {{ scc_mail }}"
command: "SUSEConnect -p SUSE-Manager-Server/{{ suma_release }}/x86_64 -r {{ scc_reg_code }} -e {{ scc_mail }}"
when:
- scc_check_registration
- 'scc_registration.stdout | from_json | json_query(query_filter) | join | lower != "registered"'
Expand Down

0 comments on commit 1a2af80

Please sign in to comment.