Skip to content

Commit

Permalink
Added support for openSUSE 42.3 (#112)
Browse files Browse the repository at this point in the history
Using `zypper` package manager.
  • Loading branch information
freemanjp authored Apr 10, 2018
1 parent 69c52e2 commit 2998664
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ matrix:
- env:
- ANSIBLE_VERSION=2.3.3
- MOLECULE_SCENARIO=fedora
- env:
- ANSIBLE_VERSION=2.3.3
- MOLECULE_SCENARIO=opensuse
- env:
- ANSIBLE_VERSION=2.4.4
- MOLECULE_SCENARIO=centos-7
Expand All @@ -24,6 +27,9 @@ matrix:
- env:
- ANSIBLE_VERSION=2.4.4
- MOLECULE_SCENARIO=fedora
- env:
- ANSIBLE_VERSION=2.4.4
- MOLECULE_SCENARIO=opensuse

# Require the standard build environment
sudo: required
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ Requirements

* 27

* SUSE

* Leap

* 42.3

* Note: other versions are likely to work but have not been tested.

Role Variables
--------------

Expand Down
9 changes: 9 additions & 0 deletions molecule/opensuse/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Molecule managed

FROM {{ item.image }}

RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; fi
16 changes: 16 additions & 0 deletions molecule/opensuse/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
*******
Install
*******

Requirements
============

* Docker Engine
* docker-py

Install
=======

.. code-block:: bash
$ sudo pip install docker-py
31 changes: 31 additions & 0 deletions molecule/opensuse/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
dependency:
name: galaxy

driver:
name: docker

lint:
name: yamllint

platforms:
- name: ansible-role-visual-studio-code-opensuse
image: opensuse:42.3

provisioner:
name: ansible
playbooks:
create: ../default/create.yml
destroy: ../default/destroy.yml
prepare: ../default/prepare.yml
converge: ../default/playbook.yml
lint:
name: ansible-lint

scenario:
name: opensuse

verifier:
name: testinfra
lint:
name: flake8
10 changes: 10 additions & 0 deletions molecule/opensuse/tests/test_install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import os

import testinfra.utils.ansible_runner

testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')


def test_visual_studio_code(Command):
assert Command('which code').rc == 0
17 changes: 17 additions & 0 deletions molecule/opensuse/tests/test_install_extensions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os
import pytest

import testinfra.utils.ansible_runner

testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')


@pytest.mark.parametrize('extension', [
'ms-python.python',
'wholroyd.jinja'
])
def test_visual_studio_code(Command, extension):
output = Command.check_output('sudo --user test_usr -H code %s %s',
'--install-extension', extension)
assert 'already installed' in output
17 changes: 17 additions & 0 deletions molecule/opensuse/tests/test_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os

import testinfra.utils.ansible_runner

testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')


def test_settings(File):
settings_file = File('/home/test_usr/.config/Code/User/settings.json')

assert settings_file.exists
assert settings_file.is_file
assert settings_file.user == 'test_usr'
assert settings_file.group == 'users'
assert oct(settings_file.mode) == '0600'
assert settings_file.contains('"Vagrantfile": "ruby"')
21 changes: 21 additions & 0 deletions tasks/install-zypper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
- name: install key (zypper)
become: yes
rpm_key:
state: present
key: https://packages.microsoft.com/keys/microsoft.asc

- name: write repo configuration (zypper)
become: yes
template:
src: vscode.repo.j2
dest: '/etc/zypp/repos.d/vscode.repo'
mode: 'u=rw,go='
owner: root
group: root

- name: install VS Code (zypper)
become: yes
zypper:
name: "code{{ (visual_studio_code_version != '') | ternary('=' + visual_studio_code_version, '') }}"
state: present
5 changes: 4 additions & 1 deletion tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: assert supported distribution
assert:
that:
- "ansible_pkg_mgr in ('apt', 'yum', 'dnf')"
- "ansible_pkg_mgr in ('apt', 'yum', 'dnf', 'zypper')"

- include: install-apt.yml
when: ansible_pkg_mgr == 'apt'
Expand All @@ -12,3 +12,6 @@

- include: install-dnf.yml
when: ansible_pkg_mgr == 'dnf'

- include: install-zypper.yml
when: ansible_pkg_mgr == 'zypper'
8 changes: 8 additions & 0 deletions templates/vscode.repo.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{ ansible_managed | comment }}
[code]
name=Visual Studio Code
baseurl=https://packages.microsoft.com/yumrepos/vscode
enabled=1
type=rpm-md
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc

0 comments on commit 2998664

Please sign in to comment.