diff --git a/.travis.yml b/.travis.yml index 05282b9..4534fea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ --- sudo: required language: python +python: 2.7 services: - docker before_install: diff --git a/defaults/main.yml b/defaults/main.yml index c72edf3..576dba2 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -4,7 +4,7 @@ # dependencies default var sb_app_install_java: true sb_app_create_users: true -sb_java_package: java-1.8.0-openjdk +sb_java_package: "{{ 'java-1.8.0-openjdk' if (ansible_distribution in ['RedHat','CentOS']) else 'openjdk-8-jdk' }}" sb_app_state: present sb_app_extension: jar diff --git a/molecule/default/Dockerfile.j2 b/molecule/default/Dockerfile.j2 index f8b4e75..829eaeb 100644 --- a/molecule/default/Dockerfile.j2 +++ b/molecule/default/Dockerfile.j2 @@ -2,7 +2,7 @@ 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; \ +RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates curl && 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; \ diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 8cd6276..14635b6 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -18,6 +18,12 @@ platforms: privileged: True command: '/sbin/init' cap_add: ['SYS_ADMIN', 'SETPCAP'] + - name: sb_ubuntu18-$TOX_ENVNAME + image: solita/ubuntu-systemd + command: /sbin/init + privileged: true + volumes: + - /lib/modules:/lib/modules:ro provisioner: name: ansible lint: diff --git a/molecule/default/playbook.yml b/molecule/default/playbook.yml index 58d5d11..1b1bc07 100644 --- a/molecule/default/playbook.yml +++ b/molecule/default/playbook.yml @@ -2,7 +2,6 @@ - name: Converge hosts: all vars: - sb_java_package: java-1.8.0-openjdk sb_user_groups_definitions: - name: sbgroup sb_users_definition: diff --git a/molecule/default/tests/test_default.py b/molecule/default/tests/test_default.py index 484c16c..9009edb 100644 --- a/molecule/default/tests/test_default.py +++ b/molecule/default/tests/test_default.py @@ -9,7 +9,7 @@ def test_service_is_started(host): ansible_vars = host.ansible.get_variables() - if (ansible_vars['inventory_hostname'] == 'sb_centos6'): + if (ansible_vars['inventory_hostname'].startswith('sb_centos6')): f = host.file('/etc/init.d/simple-springboot-app') assert f.exists assert f.user == 'sbuser' diff --git a/tasks/main.yml b/tasks/main.yml index 93ad418..67add9c 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -14,12 +14,12 @@ sb_app_artifact_destination_file: "{{ sb_app_artifact_destination_folder }}/{{ sb_app_artifact_id }}-{{ sb_app_version }}.{{ sb_app_extension }}" - name: " Service | Check if use systemd" - set_fact: use_system_d={{ (ansible_distribution in ['RedHat','CentOS'] and ansible_distribution_version is version_compare('7', '>=')) }} + set_fact: use_system_d={{ ansible_service_mgr == 'systemd' }} - debug: var=ansible_distribution_version - name: " Service | Check if use use_initd" - set_fact: use_initd={{ (ansible_distribution in ['RedHat','CentOS'] and ansible_distribution_version is version_compare('7', '<')) }} + set_fact: use_initd={{ ansible_service_mgr == 'sysvinit' }} - import_tasks: install.yml when: > diff --git a/vars/main.yml b/vars/main.yml index 30e5cb6..d0c5260 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,5 +1,5 @@ --- # vars file for role_spring_boot_app -sysd_user_services_folder: /usr/lib/systemd/system +sysd_user_services_folder: "{{ '/usr/lib/systemd/system' if (ansible_distribution in ['RedHat','CentOS']) else '/lib/systemd/system/' }}" sysd_script: "{{ sysd_user_services_folder }}/{{ sb_app_name | lower }}.service"