diff --git a/.ansible-lint b/.ansible-lint index 142c0e2..7e0172a 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -2,4 +2,3 @@ warn_list: - role-name - name[casing] - - '204' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 061a89f..5e5c0cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,9 @@ jobs: python-version: '3.x' - name: Install test dependencies - run: pip install ansible-lint[community,yamllint] + run: | + pip install ansible-lint + ansible-galaxy install -r requirements.yml - name: Lint code run: | @@ -43,11 +45,8 @@ jobs: matrix: include: - distro: debian8 - ansible-version: '<2.10' - distro: debian9 - distro: debian10 - - distro: ubuntu1604 - ansible-version: '>=2.9, <2.10' - distro: ubuntu1604 ansible-version: '>=2.10, <2.11' - distro: ubuntu1604 @@ -73,7 +72,7 @@ jobs: molecule test env: ANSIBLE_FORCE_COLOR: '1' - ANSIBLE_VERBOSITY: '3' + ANSIBLE_VERBOSITY: '2' MOLECULE_DEBUG: '1' MOLECULE_DISTRO: "${{ matrix.distro }}" PY_COLORS: '1' diff --git a/Dockerfile b/Dockerfile index b179278..6ebe0c4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,20 @@ -FROM ubuntu:16.04 +FROM ubuntu:18.04 MAINTAINER Mischa ter Smitten +ENV LANG C.UTF-8 +ENV LC_ALL C.UTF-8 + # python RUN apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install -y python-minimal python-dev curl && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y python3-minimal python3-dev curl && \ apt-get clean -RUN curl -sL https://bootstrap.pypa.io/pip/2.7/get-pip.py | python - +RUN curl -sL https://bootstrap.pypa.io/pip/3.6/get-pip.py | python3 - RUN rm -rf $HOME/.cache # ansible -RUN DEBIAN_FRONTEND=noninteractive apt-get install -y gcc libffi-dev libssl-dev && \ +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y python3-apt && \ apt-get clean -RUN pip install ansible==2.9.15 +RUN pip3 install ansible==2.10.7 RUN rm -rf $HOME/.cache # provision diff --git a/README.md b/README.md index 8f797f9..7607a91 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ None #### Variables -* `vagrant_version` [default: `2.3.1`]: Version to install +None ## Dependencies diff --git a/defaults/main.yml b/defaults/main.yml index 8636728..d3c5414 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,3 +1,2 @@ # defaults file --- -vagrant_version: 2.3.1 diff --git a/meta/main.yml b/meta/main.yml index 5a6f637..1891b88 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,13 +1,12 @@ # meta file --- galaxy_info: - namespace: oefenweb + author: oefenweb role_name: vagrant - author: Mischa ter Smitten company: Oefenweb.nl B.V. description: Set up Vagrant in Debian-like systems license: MIT - min_ansible_version: 2.9.0 + min_ansible_version: 2.10.0 platforms: - name: Ubuntu versions: diff --git a/molecule/default/collections.yml b/molecule/default/collections.yml new file mode 100644 index 0000000..c3d7e2a --- /dev/null +++ b/molecule/default/collections.yml @@ -0,0 +1,6 @@ +--- +collections: + - name: community.docker + version: '>=1.2.0,<2' + - name: community.general + version: '>=2,<3' diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000..3d5f1cd --- /dev/null +++ b/requirements.yml @@ -0,0 +1,3 @@ +# requirements file +--- +collections: [] diff --git a/tasks/install.yml b/tasks/install.yml new file mode 100644 index 0000000..938171c --- /dev/null +++ b/tasks/install.yml @@ -0,0 +1,8 @@ +# tasks file +--- +- name: install | dependencies + ansible.builtin.apt: + name: "{{ vagrant_dependencies }}" + state: "{{ apt_install_state | default('latest') }}" + tags: + - vagrant-install-dependencies diff --git a/tasks/main.yml b/tasks/main.yml index 25dbab2..7ccfd57 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,33 +1,13 @@ # tasks file --- -- name: create (download) directory - file: - path: "{{ vagrant_downloads_path }}" - state: directory - owner: root - group: root - mode: 0755 +- ansible.builtin.import_tasks: repository.yml tags: - configuration - vagrant - - vagrant-download + - vagrant-repository -- name: download - get_url: - url: "https://releases.hashicorp.com/vagrant/{{ vagrant_version }}/vagrant_{{ vagrant_version }}_{{ ansible_machine }}.deb" - dest: "{{ vagrant_downloads_path }}/vagrant_{{ vagrant_version }}_{{ ansible_machine }}.deb" - owner: root - group: root - mode: 0644 +- ansible.builtin.import_tasks: install.yml tags: - configuration - vagrant - - vagrant-download - -- name: install deb file - apt: - deb: "{{ vagrant_downloads_path }}/vagrant_{{ vagrant_version }}_{{ ansible_machine }}.deb" - tags: - - configuration - - vagrant - - vagrant-install-deb + - vagrant-install diff --git a/tasks/repository.yml b/tasks/repository.yml new file mode 100644 index 0000000..bb8057f --- /dev/null +++ b/tasks/repository.yml @@ -0,0 +1,27 @@ +# tasks file +--- +- name: repository | install dependencies (pre) + ansible.builtin.apt: + name: "{{ vagrant_dependencies_pre }}" + state: "{{ apt_install_state | default('latest') }}" + update_cache: true + cache_valid_time: "{{ apt_update_cache_valid_time | default(3600) }}" + tags: + - vagrant-repository-install-dependencies + +- name: repository | add public key + ansible.builtin.apt_key: + id: DA418C88A3219F7B + url: https://apt.releases.hashicorp.com/gpg + state: present + tags: + - vagrant-repository-public-key + +- name: repository | add + ansible.builtin.apt_repository: + repo: "{{ item.type }} {{ item.url }} {{ item.component }}" + state: present + update_cache: true + with_items: "{{ vagrant_repositories }}" + tags: + - vagrant-repository-add diff --git a/tests/tasks/post.yml b/tests/tasks/post.yml new file mode 100644 index 0000000..63345d7 --- /dev/null +++ b/tests/tasks/post.yml @@ -0,0 +1,6 @@ +# post test file +--- +- name: test installation + ansible.builtin.command: > + vagrant --version + changed_when: false diff --git a/tests/test.yml b/tests/test.yml index be2b897..b1d0a7d 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -5,3 +5,6 @@ become: true roles: - ../../ + post_tasks: + - name: include tasks + ansible.builtin.import_tasks: "{{ playbook_dir }}/tasks/post.yml" diff --git a/tests/vagrant.yml b/tests/vagrant.yml index afdaebc..cb458a1 100644 --- a/tests/vagrant.yml +++ b/tests/vagrant.yml @@ -5,3 +5,6 @@ become: true roles: - ../../ + post_tasks: + - name: include tasks + ansible.builtin.import_tasks: "{{ playbook_dir }}/tasks/post.yml" diff --git a/vars/main.yml b/vars/main.yml index 2d16acf..e5b9603 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,3 +1,14 @@ # vars file --- -vagrant_downloads_path: /var/lib/ansible/vagrant/downloads +vagrant_repositories: + - type: deb + url: "https://apt.releases.hashicorp.com {{ ansible_distribution_release }}" + component: main + +vagrant_dependencies_pre: + - software-properties-common + - dirmngr + - apt-transport-https + +vagrant_dependencies: + - vagrant