diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 0000000..c099c60 --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,2 @@ +warn_list: + - '106' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..5b2c3bf --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,81 @@ +--- +name: CI +'on': + pull_request: + push: + branches: + - master + schedule: + - cron: '30 1 * * 3' + +jobs: + + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Check out the codebase + uses: actions/checkout@v2 + + - name: Set up Python 3 + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install test dependencies + run: pip install ansible-lint[community,yamllint] + + - name: Lint code + run: | + yamllint . + ansible-lint + + molecule: + name: Molecule + runs-on: ubuntu-latest + defaults: + run: + working-directory: "${{ github.repository }}" + needs: + - lint + strategy: + fail-fast: false + matrix: + include: + - distro: debian8 + ansible-version: '<2.10' + - distro: debian9 + - distro: debian10 + - distro: ubuntu1604 + ansible-version: '>=2.8, <2.9' + - distro: ubuntu1604 + ansible-version: '>=2.9, <2.10' + - distro: ubuntu1604 + ansible-version: '>=2.10, <2.11' + - distro: ubuntu1604 + - distro: ubuntu1804 + - distro: ubuntu2004 + + steps: + - name: Check out the codebase + uses: actions/checkout@v2 + with: + path: "${{ github.repository }}" + + - name: Set up Python 3 + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install test dependencies + run: pip install 'ansible${{ matrix.ansible-version }}' molecule[docker] docker + + - name: Run Molecule tests + run: | + molecule test + env: + ANSIBLE_FORCE_COLOR: '1' + ANSIBLE_VERBOSITY: '3' + MOLECULE_DEBUG: '1' + MOLECULE_DISTRO: "${{ matrix.distro }}" + PY_COLORS: '1' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2354e68 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,20 @@ +--- +name: Release +'on': + push: + tags: + - '*' + +jobs: + + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Check out the codebase + uses: actions/checkout@v2 + + - name: Publish to Galaxy + uses: robertdebock/galaxy-action@1.1.0 + with: + galaxy_api_key: ${{ secrets.GALAXY_API_KEY }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b9aab67..0000000 --- a/.travis.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -sudo: required -dist: xenial - -language: python -python: - - "2.7" - - "3.5" - -env: - - ANSIBLE_VERSION=latest - - ANSIBLE_VERSION=2.10.2 - - ANSIBLE_VERSION=2.10.1 - - ANSIBLE_VERSION=2.10.0 - - ANSIBLE_VERSION=2.9.14 - - ANSIBLE_VERSION=2.9.13 - - ANSIBLE_VERSION=2.9.12 - - ANSIBLE_VERSION=2.9.11 - - ANSIBLE_VERSION=2.9.10 - - ANSIBLE_VERSION=2.9.9 - - ANSIBLE_VERSION=2.9.8 - - ANSIBLE_VERSION=2.9.7 - - ANSIBLE_VERSION=2.9.6 - - ANSIBLE_VERSION=2.9.5 - - ANSIBLE_VERSION=2.9.4 - - ANSIBLE_VERSION=2.9.3 - - ANSIBLE_VERSION=2.9.2 - - ANSIBLE_VERSION=2.9.1 - - ANSIBLE_VERSION=2.9.0 - - ANSIBLE_VERSION=2.8.16 - - ANSIBLE_VERSION=2.8.15 - - ANSIBLE_VERSION=2.8.14 - - ANSIBLE_VERSION=2.8.13 - - ANSIBLE_VERSION=2.8.12 - - ANSIBLE_VERSION=2.8.11 - - ANSIBLE_VERSION=2.8.10 - - ANSIBLE_VERSION=2.8.9 - - ANSIBLE_VERSION=2.8.8 - - ANSIBLE_VERSION=2.8.7 - - ANSIBLE_VERSION=2.8.6 - - ANSIBLE_VERSION=2.8.5 - - ANSIBLE_VERSION=2.8.4 - - ANSIBLE_VERSION=2.8.3 - - ANSIBLE_VERSION=2.8.2 - - ANSIBLE_VERSION=2.8.1 - - ANSIBLE_VERSION=2.8.0 - -branches: - only: - - master - -before_install: - - sudo apt-get update -qq - -install: - # Install Ansible. - - if [ "$ANSIBLE_VERSION" = "latest" ]; then pip install ansible; else pip install ansible==$ANSIBLE_VERSION; fi - - if [ "$ANSIBLE_VERSION" = "latest" ]; then pip install ansible-lint; fi - -script: - # Check the role/playbook's syntax. - - ansible-playbook -i tests/inventory tests/test.yml --syntax-check - - # Run the role/playbook with ansible-playbook. - - ansible-playbook -i tests/inventory tests/test.yml -vvvv - - # Run the role/playbook again, checking to make sure it's idempotent. - - > - ansible-playbook -i tests/inventory tests/test.yml - | grep -q 'changed=0.*failed=0' - && (echo 'Idempotence test: pass' && exit 0) - || (echo 'Idempotence test: fail' && exit 1) - - - if [ "$ANSIBLE_VERSION" = "latest" ]; then ansible-lint tests/test.yml; fi - -notifications: - email: false - webhooks: https://galaxy.ansible.com/api/v1/notifications/ - slack: - rooms: - secure: "YsivJeVnllOeFjr4ztXAluZ4h7h6Hnfd8o5HmTtoGyi7L5Kn1hwGuJzQYLm6XJ0NLk7Y86cZPla+xSJyf9/YSDwXubETr+2XHb4JwPUNyi5LJ7SlrvGHtlm7L5jAXeTL9EycRXf6kTVOZzbGLrE+O7dAqt+nowDZDq+Fy0QfKej/KpcKBVuF1eoMqPEi0x26bAccsq2nYTlWM8Vjvujt7LNKR0Jdj9yFvhK8I2aVo5jhT8CO5xurHd0qEK8ZeQ3xrnBH4Yoys6oZzMTycZK03s56RtFoifX3nBi+AwYk5PYAqAFNm3rfO7NZcC7t55aZ+ZzIBvFG6TfHYXwRUb5Jpg/d7srWo1VWO3Ueqzt9yY0Dayt2NSOUjrPVgDjsBlUiPxP2UJoICwFmuJiP07VEEgS3TQyv93Y7sag9GjUsZg8BOG+xL1gSjVrbtLBZH9Tyeys/FHtcrbMSmNumpwP1u4WoIF3FpAIMjYefdwTuwrSCBJOxFd3SG9sRmRWoXm1oLB0WMScHZ1RkjxHa2V2QFBLXdLskDlWcy+laeXeNpSa4QbjvqJCq/cEWgdgXqAO33qFMmc6JSRU9zm3tiCLlTH6l0d5UZgbebXN9kIEfBkz7nRAXXRUMIqTZ2GoIZuZ9iSnW8UdPyq9+VTZuBwB0qsBb9fQPPyBC6D/6kFlw1Ew=" diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..894450c --- /dev/null +++ b/.yamllint @@ -0,0 +1,15 @@ +--- +extends: default + +rules: + braces: + max-spaces-inside: 1 + level: error + brackets: + max-spaces-inside: 1 + level: error + line-length: disable + truthy: disable + +ignore: | + .tox/ diff --git a/README.md b/README.md index 2fda4c6..045031a 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,14 @@ ## virtualbox -[![Build Status](https://travis-ci.org/Oefenweb/ansible-virtualbox.svg?branch=master)](https://travis-ci.org/Oefenweb/ansible-virtualbox) +[![CI](https://github.com/Oefenweb/ansible-virtualbox/workflows/CI/badge.svg)](https://github.com/Oefenweb/ansible-virtualbox/actions?query=workflow%3ACI) [![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-virtualbox-blue.svg)](https://galaxy.ansible.com/Oefenweb/virtualbox/) Set up [VirtualBox](https://www.virtualbox.org/) in Debian-like systems. #### Requirements -None +* `software-properties-common` (will be installed) +* `dirmngr` (will be installed) #### Variables diff --git a/Vagrantfile b/Vagrantfile index 368fbf1..a0182a0 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -4,33 +4,26 @@ role = File.basename(File.expand_path(File.dirname(__FILE__))) boxes = [ - { - :name => "ubuntu-1404", - :box => "bento/ubuntu-14.04", - :ip => '10.0.0.12', - :cpu => "50", - :ram => "256" - }, { :name => "ubuntu-1604", :box => "bento/ubuntu-16.04", - :ip => '10.0.0.13', + :ip => '10.0.0.12', :cpu => "50", :ram => "256" }, { :name => "ubuntu-1804", :box => "bento/ubuntu-18.04", - :ip => '10.0.0.14', + :ip => '10.0.0.13', :cpu => "50", :ram => "384" }, { - :name => "debian-7", - :box => "bento/debian-7", - :ip => '10.0.0.15', + :name => "ubuntu-2004", + :box => "bento/ubuntu-20.04", + :ip => '10.0.0.14', :cpu => "50", - :ram => "256" + :ram => "384" }, { :name => "debian-8", diff --git a/meta/main.yml b/meta/main.yml index 1546180..e65af57 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -11,12 +11,11 @@ galaxy_info: platforms: - name: Ubuntu versions: - - trusty - xenial - bionic + - focal - name: Debian versions: - - wheezy - jessie - stretch - buster diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml new file mode 100644 index 0000000..153a4fe --- /dev/null +++ b/molecule/default/converge.yml @@ -0,0 +1,7 @@ +--- +- name: Converge + hosts: all + become: true + tasks: [] + roles: + - ../../../ diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml new file mode 100644 index 0000000..fbb7120 --- /dev/null +++ b/molecule/default/molecule.yml @@ -0,0 +1,19 @@ +--- +dependency: + name: galaxy +driver: + name: docker +platforms: + - name: instance + image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu1604}-ansible:latest" + command: ${MOLECULE_DOCKER_COMMAND:-""} + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: true + pre_build_image: true +provisioner: + name: ansible + playbooks: + prepare: prepare.yml + converge: converge.yml + verify: verify.yml diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml new file mode 100644 index 0000000..9a6673d --- /dev/null +++ b/molecule/default/prepare.yml @@ -0,0 +1,5 @@ +--- +- name: Prepare + hosts: all + become: true + tasks: [] diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml new file mode 100644 index 0000000..44debad --- /dev/null +++ b/molecule/default/verify.yml @@ -0,0 +1,5 @@ +--- +- name: Verify + hosts: all + become: true + tasks: [] diff --git a/tasks/install.yml b/tasks/install.yml index 6a99046..9630f7f 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -1,13 +1,13 @@ # tasks file --- -- name: install dependencies +- name: install | dependencies apt: name: "{{ virtualbox_dependencies }}" state: "{{ apt_install_state | default('latest') }}" tags: - virtualbox-install-dependencies -- name: install +- name: install | additional apt: name: "{{ virtualbox_install }}" state: "{{ apt_install_state | default('latest') }}" diff --git a/tasks/repository.yml b/tasks/repository.yml index d2ad302..8c88eb9 100644 --- a/tasks/repository.yml +++ b/tasks/repository.yml @@ -1,6 +1,16 @@ # tasks file --- -- name: add public key +- name: repository | install | dependencies (pre) + apt: + name: "{{ virtualbox_dependencies_pre }}" + state: "{{ apt_install_state | default('latest') }}" + update_cache: true + cache_valid_time: "{{ apt_update_cache_valid_time | default(3600) }}" + tags: + - virtualbox-repository-install + - virtualbox-repository-install-dependencies + +- name: repository | add public key apt_key: id: "{{ item.id }}" url: "{{ item.url }}" @@ -9,7 +19,7 @@ tags: - virtualbox-repository-public-key -- name: add virtualbox repository +- name: repository | add repository apt_repository: repo: "{{ item.type }} {{ item.url }} {{ item.component }}" state: present diff --git a/vars/main.yml b/vars/main.yml index 0c87705..f0f9f95 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -10,5 +10,9 @@ virtualbox_public_keys: - id: A2F683C52980AECF url: https://www.virtualbox.org/download/oracle_vbox_2016.asc +virtualbox_dependencies_pre: + - software-properties-common + - dirmngr + virtualbox_dependencies: - "virtualbox-{{ virtualbox_version }}"