Skip to content
Snippets Groups Projects
Commit 1e656e60 authored by Alice Heaton's avatar Alice Heaton :speech_balloon:
Browse files

Ensure we become root before installing package, and add a Vagrant test as the...

Ensure we become root before installing package, and add a Vagrant test as the docker test didn't catch that
parent 5251cd22
No related branches found
No related tags found
1 merge request!4Ensure we become root before installing package, and add a Vagrant test as the…
Pipeline #2504 failed
......@@ -12,3 +12,4 @@ python_version = "3.6"
docker = "*"
molecule = "*"
linode-python = "*"
python-vagrant = "*"
......@@ -46,6 +46,12 @@ To run the tests do:
$pipenv run molecule test
```
Or the vagrant variant:
```
$pipenv run molecue test -s vagrant
```
The tests should pass. As this is a CentOs 6 and 7 module at the moment, the default scenario runs on CentOS 6 and 7. To make sure the role fails with an error on other platforms, you can test the 'fail' scenario:
```
......
*******
Vagrant driver installation guide
*******
Requirements
============
* Vagrant
* Virtualbox, Parallels, VMware Fusion, VMware Workstation or VMware Desktop
* python-vagrant
Install
=======
.. code-block:: bash
$ sudo pip install python-vagrant
---
dependency:
name: galaxy
driver:
name: vagrant
provider:
name: virtualbox
lint:
name: yamllint
platforms:
- name: centos7
box: centos/7
provisioner:
name: ansible
lint:
name: ansible-lint
scenario:
name: vagrant
verifier:
name: testinfra
lint:
name: flake8
---
- name: Converge
hosts: all
roles:
- role: software-collections
---
- name: Prepare
hosts: all
gather_facts: false
tasks:
- name: Install python for Ansible
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
become: true
changed_when: false
import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
def test_scl_is_installed(host):
package = host.package('centos-release-scl')
assert package.is_installed
def test_sclo_rh_repository_is_enabled(host):
cmd = host.run('yum repolist enabled | grep centos-sclo-rh | wc -l')
assert cmd.rc == 0
assert int(cmd.stdout.strip()) == 1
def test_sclo_sclo_repository_is_enabled(host):
cmd = host.run('yum repolist enabled | grep centos-sclo-sclo | wc -l')
assert cmd.rc == 0
assert int(cmd.stdout.strip()) == 1
......@@ -10,6 +10,8 @@
when: not (distro_ok and version_ok)
- name: Add Software Collections for CentOS
become: true
become_user: root
yum:
name: centos-release-scl
state: present
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment