diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 0000000..e4ec007 --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,2 @@ +skip_list: + - '303' diff --git a/.markdownlint.yml b/.markdownlint.yml new file mode 100644 index 0000000..0d03183 --- /dev/null +++ b/.markdownlint.yml @@ -0,0 +1,4 @@ +--- +"MD013": false # line-length +"MD014": false # show commands output +"MD041": false # first line should be heading (build status image) diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 0000000..0c01e2b --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,3 @@ +--- +rules: + line-length: disable diff --git a/README.md b/README.md index 9243e6c..00e0f31 100644 --- a/README.md +++ b/README.md @@ -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 | @@ -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 diff --git a/defaults/main.yml b/defaults/main.yml index cd8172e..55c886a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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 diff --git a/meta/main.yml b/meta/main.yml index fc65bd9..20c79c5 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -11,7 +11,7 @@ galaxy_info: platforms: - name: opensuse versions: - - 15.1 + - 15.2 - name: sles versions: - 15 diff --git a/molecule/README.md b/molecule/README.md index a55844b..fc3b3ad 100644 --- a/molecule/README.md +++ b/molecule/README.md @@ -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 @@ -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 @@ -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--GM.vagrant..box +``` + +Replace `` 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 @@ -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. diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index a7b5dfd..6628d85 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -3,6 +3,7 @@ hosts: all roles: - role: ansible-uyuni + use_lvm: false config_firewall: false setup_cefs: true setup_cefs_cronjob: true diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index ec29d7d..0d4bfbb 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -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: diff --git a/molecule/default/vars/main.yml b/molecule/default/vars/main.yml index 0280870..209145e 100644 --- a/molecule/default/vars/main.yml +++ b/molecule/default/vars/main.yml @@ -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" diff --git a/molecule/suma/converge.yml b/molecule/suma/converge.yml index 90abf78..c2702e3 100644 --- a/molecule/suma/converge.yml +++ b/molecule/suma/converge.yml @@ -3,8 +3,9 @@ hosts: all roles: - role: ansible-uyuni - scc_reg_code: - scc_mail: + use_lvm: false + scc_reg_code: "" + scc_mail: "" config_firewall: false setup_cefs: true setup_cefs_cronjob: true diff --git a/molecule/suma/molecule.yml b/molecule/suma/molecule.yml index 85c3f3b..20b630c 100644 --- a/molecule/suma/molecule.yml +++ b/molecule/suma/molecule.yml @@ -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: diff --git a/molecule/suma/vars/main.yml b/molecule/suma/vars/main.yml index 682bd37..5a0bc64 100644 --- a/molecule/suma/vars/main.yml +++ b/molecule/suma/vars/main.yml @@ -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" diff --git a/tasks/check.yml b/tasks/check.yml deleted file mode 100644 index 12cb99d..0000000 --- a/tasks/check.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -- name: Ensure having 15 SP1 release - fail: msg="Please upgrade to SP1" - when: "ansible_distribution_version != '15.1'" diff --git a/tasks/check_opensuse_leap.yml b/tasks/check_opensuse_leap.yml new file mode 100644 index 0000000..187a1b2 --- /dev/null +++ b/tasks/check_opensuse_leap.yml @@ -0,0 +1,4 @@ +--- +- name: Ensure having 15 SP2 release + fail: msg="Please upgrade to SP2" + when: "ansible_distribution_version != '15.2'" diff --git a/tasks/check_sles.yml b/tasks/check_sles.yml new file mode 100644 index 0000000..15bd241 --- /dev/null +++ b/tasks/check_sles.yml @@ -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' diff --git a/tasks/install.yml b/tasks/install.yml index b15d127..7c59492 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -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 diff --git a/tasks/main.yml b/tasks/main.yml index c2481f8..7f6bb5a 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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" diff --git a/tasks/prepare.yml b/tasks/prepare.yml index ae5babb..5daf12f 100644 --- a/tasks/prepare.yml +++ b/tasks/prepare.yml @@ -1,10 +1,4 @@ --- -- name: Update system - zypper: - name: "*" - state: latest - become: true - - name: Install core utilities zypper: name: "{{ core_packages }}" diff --git a/tasks/prepare_sles.yml b/tasks/prepare_sles.yml index b57e304..1078659 100644 --- a/tasks/prepare_sles.yml +++ b/tasks/prepare_sles.yml @@ -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"'