From 24ee46b3f08bbadc291a231560c73eed09f3c2f5 Mon Sep 17 00:00:00 2001 From: Pablo Escobar Date: Thu, 7 May 2020 11:24:09 +0200 Subject: [PATCH] update CI to only do linting checks --- .travis.yml | 8 +++--- .yamllint | 2 ++ ci-linting-checks.sh | 6 +++++ molecule/default/Dockerfile.j2 | 8 ------ molecule/default/INSTALL.rst | 16 ------------ molecule/default/create.yml | 47 ---------------------------------- molecule/default/destroy.yml | 16 ------------ molecule/default/molecule.yml | 33 ------------------------ molecule/default/playbook.yml | 6 ----- molecule/default/prepare.yml | 5 ---- molecule/tests/test_default.py | 20 --------------- 11 files changed, 11 insertions(+), 156 deletions(-) create mode 100644 ci-linting-checks.sh delete mode 100644 molecule/default/Dockerfile.j2 delete mode 100644 molecule/default/INSTALL.rst delete mode 100644 molecule/default/create.yml delete mode 100644 molecule/default/destroy.yml delete mode 100644 molecule/default/molecule.yml delete mode 100644 molecule/default/playbook.yml delete mode 100644 molecule/default/prepare.yml delete mode 100644 molecule/tests/test_default.py diff --git a/.travis.yml b/.travis.yml index 33cdb95..3a78ec6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,11 +6,9 @@ services: before_install: - sudo apt-get -qq update install: - - pip install molecule - # - pip install required driver (e.g. docker, python-vagrant, shade, boto, apache-libcloud) - - pip install docker + - pip install ansible-lint + - pip install yamllint script: - - molecule lint - # - molecule test -s docker + - bash ci-linting-checks.sh notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/.yamllint b/.yamllint index bee2f2c..08eb857 100644 --- a/.yamllint +++ b/.yamllint @@ -1,3 +1,5 @@ +--- + extends: default rules: diff --git a/ci-linting-checks.sh b/ci-linting-checks.sh new file mode 100644 index 0000000..3dab1c4 --- /dev/null +++ b/ci-linting-checks.sh @@ -0,0 +1,6 @@ +#!/bin/bash +ansible --version +yamllint --version +ansible-lint --version +yamllint . +ansible-lint -v --exclude=./roles --exclude=./collections . diff --git a/molecule/default/Dockerfile.j2 b/molecule/default/Dockerfile.j2 deleted file mode 100644 index 0163232..0000000 --- a/molecule/default/Dockerfile.j2 +++ /dev/null @@ -1,8 +0,0 @@ -# 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 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 diff --git a/molecule/default/INSTALL.rst b/molecule/default/INSTALL.rst deleted file mode 100644 index e26493b..0000000 --- a/molecule/default/INSTALL.rst +++ /dev/null @@ -1,16 +0,0 @@ -******* -Install -******* - -Requirements -============ - -* Docker Engine -* docker-py - -Install -======= - -.. code-block:: bash - - $ sudo pip install docker-py diff --git a/molecule/default/create.yml b/molecule/default/create.yml deleted file mode 100644 index 11d5c69..0000000 --- a/molecule/default/create.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: False - no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}" - vars: - molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}" - molecule_ephemeral_directory: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}" - molecule_scenario_directory: "{{ lookup('env', 'MOLECULE_SCENARIO_DIRECTORY') }}" - molecule_yml: "{{ lookup('file', molecule_file) | molecule_from_yaml }}" - tasks: - - name: Create Dockerfiles from image names - template: - src: "{{ molecule_scenario_directory }}/Dockerfile.j2" - dest: "{{ molecule_ephemeral_directory }}/Dockerfile_{{ item.image | regex_replace('[^a-zA-Z0-9_]', '_') }}" - with_items: "{{ molecule_yml.platforms }}" - register: platforms - - - name: Discover local Docker images - docker_image_facts: - name: "molecule_local/{{ item.item.name }}" - with_items: "{{ platforms.results }}" - register: docker_images - - - name: Build an Ansible compatible image - docker_image: - path: "{{ molecule_ephemeral_directory }}" - name: "molecule_local/{{ item.item.image }}" - dockerfile: "{{ item.item.dockerfile | default(item.invocation.module_args.dest) }}" - force: "{{ item.item.force | default(True) }}" - with_items: "{{ platforms.results }}" - when: platforms.changed or docker_images.results | map(attribute='images') | select('equalto', []) | list | count >= 0 - - - name: Create molecule instance(s) - docker_container: - name: "{{ item.name }}" - hostname: "{{ item.name }}" - image: "molecule_local/{{ item.image }}" - state: started - recreate: False - log_driver: syslog - command: "{{ item.command | default('sleep infinity') }}" - privileged: "{{ item.privileged | default(omit) }}" - volumes: "{{ item.volumes | default(omit) }}" - capabilities: "{{ item.capabilities | default(omit) }}" - with_items: "{{ molecule_yml.platforms }}" diff --git a/molecule/default/destroy.yml b/molecule/default/destroy.yml deleted file mode 100644 index f31ee27..0000000 --- a/molecule/default/destroy.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: False - no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}" - vars: - molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}" - molecule_yml: "{{ lookup('file', molecule_file) | molecule_from_yaml }}" - tasks: - - name: Destroy molecule instance(s) - docker_container: - name: "{{ item.name }}" - state: absent - force_kill: "{{ item.force_kill | default(True) }}" - with_items: "{{ molecule_yml.platforms }}" diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml deleted file mode 100644 index cd35c92..0000000 --- a/molecule/default/molecule.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -dependency: - name: galaxy -driver: - name: docker -lint: - name: yamllint -platforms: - - name: centos7-systemd-docker - image: centos/systemd - # image: retr0h/centos7-systemd-ansible:latest - # image: centos:7 - privileged: True - command: /usr/sbin/init - # volumes: - # - /sys/fs/cgroup:/sys/fs/cgroup:ro -provisioner: - name: ansible - options: - become: True - lint: - name: ansible-lint - options: - R: True -scenario: - name: default -verifier: - name: testinfra - directory: ../tests - options: - verbose: True - lint: - name: flake8 diff --git a/molecule/default/playbook.yml b/molecule/default/playbook.yml deleted file mode 100644 index 1e26177..0000000 --- a/molecule/default/playbook.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -- name: Converge - hosts: all - become: True - roles: - - role: ansible-role-katello-agent diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml deleted file mode 100644 index d34f067..0000000 --- a/molecule/default/prepare.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- name: Prepare - hosts: all - gather_facts: False - tasks: [] diff --git a/molecule/tests/test_default.py b/molecule/tests/test_default.py deleted file mode 100644 index 048a860..0000000 --- a/molecule/tests/test_default.py +++ /dev/null @@ -1,20 +0,0 @@ -import os - -import testinfra.utils.ansible_runner - -testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') - - -def test_katello_agent_package(host): - assert host.package("katello-agent").is_installed - - -def test_subscription_manager_package(host): - assert host.package("subscription-manager").is_installed - - -def test_goferd_service(host): - s = host.service("goferd") - assert s.is_running - assert s.is_enabled