diff --git a/.gitignore b/.gitignore
index 242fd44..b427b2c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,10 @@
-# python
-*.pyc
-*.pyo
-__pycache__
+# Ansible
+.ansible/galaxy-roles
+.ansible/roles
+*.retry
-# vagrant
-/.ansible
-/.vagrant
+tests/.ansible/
+
+# Vagrant
+.vagrant/
+*-VBoxSVC-*.log
diff --git a/.travis.yml b/.travis.yml
index 7bc1188..b17b27e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,24 +1,17 @@
---
dist: trusty
-sudo: required
+sudo: false
-matrix:
- fast_finish: true
+language: python
+python: 3.6
+cache: pip
-services:
- - docker
+install: pip install -r requirements.txt
-env:
- global: # applied to every run
- ROLE_NAME: python-dev
-
- matrix: # each entry is its own run
- - IMAGE_NAME: naftulikay/centos-vm:7
- - IMAGE_NAME: naftulikay/xenial-vm:latest
- - IMAGE_NAME: naftulikay/trusty-vm:latest
-
-script: make test-clean
+script: travis-pls make test
notifications:
- email: { on_success: never, on_failure: never }
+ email:
+ on_success: never
+ on_failure: never
webhooks: https://galaxy.ansible.com/api/v1/notifications/
diff --git a/LICENSE-APACHE b/LICENSE-APACHE
new file mode 100644
index 0000000..82050e6
--- /dev/null
+++ b/LICENSE-APACHE
@@ -0,0 +1,13 @@
+Copyright © 2019 Naftuli Kay
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
\ No newline at end of file
diff --git a/LICENSE-MIT b/LICENSE-MIT
new file mode 100644
index 0000000..ad0928c
--- /dev/null
+++ b/LICENSE-MIT
@@ -0,0 +1,14 @@
+Copyright © 2019 Naftuli Kay
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
+documentation files (the “Software”), to deal in the Software without restriction, including without limitation the
+rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
+persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 467a05d..bc56df0 100644
--- a/Makefile
+++ b/Makefile
@@ -1,80 +1,20 @@
#!/usr/bin/make -f
-ROLE_NAME:=python-dev
-MOUNT_PATH:=/etc/ansible/roles/$(ROLE_NAME)
-# TODO trusty needs not systemd flags
-SYSTEMD_FLAGS:=--privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro
+SHELL:=$(shell which bash)
-LOCAL_FLAGS:=-v $(shell pwd):$(MOUNT_PATH):ro -v $(shell pwd)/ansible.cfg:/etc/ansible/ansible.cfg:ro
-SELINUX_FLAGS:=
+clean:
+ @docker-compose down
-CONTAINER_ID_DIR:=/tmp/container/$(IMAGE_NAME)
-CONTAINER_ID_FILE:=$(CONTAINER_ID_DIR)/id
-CONTAINER_ID:=$(shell cat "$(CONTAINER_ID_FILE)" 2>/dev/null)
+start:
+ @docker-compose up -d
-validate:
-ifeq ($(IMAGE_NAME),)
- @echo "IMAGE_NAME is undefined, please define it."
- @exit 1
-endif
-ifeq ($(ROLE_NAME),)
- @echo "ROLE_NAME is undefined, please define it."
- @exit 1
-endif
+pip:
+ @pip install -q $(shell test -z "$$TRAVIS" && echo "--user") -r requirements.txt ; \
-# get status of the vm-like container
-status: validate
- @if [ -z "$(CONTAINER_ID)" ]; then \
- echo "Container Not Running" ; \
- exit 1 ; \
- else \
- echo "Container Running" ; \
- fi
+install: pip
-start: validate
- @if [ ! -z "$(CONTAINER_ID)" ]; then \
- echo "ERROR: Container Already Running: $(CONTAINER_ID)" >&2 ; \
- exit 1 ; \
- fi
- @# start it
- @echo "Starting the Container:"
- @test -d "$(CONTAINER_ID_DIR)" || mkdir -p "$(CONTAINER_ID_DIR)"
- docker pull $(IMAGE_NAME)
- docker pull docker:stable-dind
- docker run -d --privileged --name dind docker:stable-dind
- docker run -d --link dind:docker $(SYSTEMD_FLAGS) $(LOCAL_FLAGS) $$(test -d /etc/selinux && echo $(SELINUX_FLAGS)) $(IMAGE_NAME) > $(CONTAINER_ID_FILE)
+unittest: pip
+ @if [ -e tests.py ]; then python tests.py -vvv ; fi
-stop: validate
- @if [ -z "$(CONTAINER_ID)" ] && ! docker ps --filter id=$(CONTAINER_ID) --format '{{.ID}}' | grep -qP '.*' ; then \
- echo "ERROR: Container Not Running" >&2 ; \
- rm -f $(CONTAINER_ID_FILE) ; \
- exit 0 ; \
- fi ; \
- docker kill $(CONTAINER_ID) > /dev/null ; \
- docker rm -f -v $(CONTAINER_ID) > /dev/null ; \
- docker rm -f -v dind ; \
- rm -f $(CONTAINER_ID_FILE) ; \
- echo "Stopped Container $(CONTAINER_ID)"
-
-restart:
- $(MAKE) stop
- $(MAKE) start
-
-shell: status
- docker exec -it $(CONTAINER_ID) /bin/bash -
-
-test:
- @if [ -z "$(CONTAINER_ID)" ]; then \
- echo "ERROR: Container Not Running" >&2 ; \
- exit 1 ; \
- fi
- @# need a way to ask systemd in the container to wait until all services up
- docker exec $(CONTAINER_ID) ansible --version
- docker exec $(CONTAINER_ID) wait-for-boot
- docker exec $(CONTAINER_ID) ansible-galaxy install --force -r ${MOUNT_PATH}/tests/requirements.yml
- docker exec $(CONTAINER_ID) env ANSIBLE_FORCE_COLOR=yes \
- ansible-playbook $(MOUNT_PATH)/tests/playbook.yml
-
-test-clean:
- $(MAKE) restart
- $(MAKE) test
+test: install start unittest
+ @make -C tests/ test
\ No newline at end of file
diff --git a/README.md b/README.md
index 9428baa..4b6f76a 100644
--- a/README.md
+++ b/README.md
@@ -1,70 +1,17 @@
-# ansible-role-python-dev [![Build Status][img-build-status]][build-status]
+# ansible-role-python-dev [![Build Status][travis.svg]][travis]
Installs and configures a Python development environment for a given user using [`pyenv`][pyenv].
Available on Ansible Galaxy at [`naftulikay.python-dev`][galaxy].
-## Requirements
-
-Officially tested operating systems are listed in the Galaxy manifest.
-
-## Role Variables
-
-
- python_user
- - User to install Python tools for. Required.
- python_version
- - Version of Python to install. Defaults to 2.7.
- addtl_python_system_packages
- - A list of additional system packages to install.
- addtl_python_pip_system_packages
- - A list of additional Python system packages to install via pip.
- addtl_python_pip_user_packages
- - A list of additional Python user packages to install via pip.
-
-
-## Dependencies
-
-None.
-
-## Example Playbook
-
-Here are some example playbooks to get started with.
-
-### Defaults
-
-Simply get a Python development environment installed:
-
-```yaml
----
-- name: install
- hosts: all
- become: true
- roles:
- - role: python-dev
- python_user: vagrant
-```
-
-### Install a Specific Version
-
-Install a specific version of Python:
-
-```yaml
----
- - name: install
- hosts: all
- become: true
- roles:
- - role: python-dev
- python_user: vagrant
- python_version: '3.5'
-```
-
## License
-MIT
+Licensed at your discretion under either:
+
+ - [Apache Software License, Version 2.0](./LICENSE-APACHE)
+ - [MIT License](./LICENSE-MIT)
- [build-status]: https://travis-ci.org/naftulikay/ansible-role-python-dev
- [img-build-status]: https://travis-ci.org/naftulikay/ansible-role-python-dev.svg?branch=master
[galaxy]: https://galaxy.ansible.com/naftulikay/python-dev/
[pyenv]: https://github.com/pyenv/pyenv
+ [travis.svg]: https://travis-ci.org/naftulikay/ansible-role-python-dev.svg?branch=master
+ [travis]: https://travis-ci.org/naftulikay/ansible-role-python-dev
diff --git a/Vagrantfile b/Vagrantfile
index cb04b36..e574871 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -11,7 +11,7 @@ VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "bento/centos-7.4"
- config.vm.hostname = "devel"
+ config.vm.hostname = File.expand_path(File.dirname(__FILE__)).split('/')[-1]
# Create a private network, which allows host-only access to the machine
# using a specific IP.
@@ -33,4 +33,4 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# allow passing ansible args from environment variable
ansible.raw_arguments = Shellwords::shellwords(ENV.fetch("ANSIBLE_ARGS", ""))
end
-end
+end
\ No newline at end of file
diff --git a/ansible.cfg b/ansible.cfg
index 7cd9275..84a6091 100644
--- a/ansible.cfg
+++ b/ansible.cfg
@@ -1,5 +1,3 @@
[defaults]
retry_files_enabled = false
-
-[galaxy]
-role_skeleton_ignore = ^.git(ignore)?$,^\.travis\.yml$,^tests,^(Vagrantfile|vagrant\.yml|\.vagrant)$,^Makefile$
+roles_path = .ansible/galaxy-roles
\ No newline at end of file
diff --git a/defaults/main.yml b/defaults/main.yml
index ed97d53..62826c6 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -1 +1,3 @@
---
+python_user: null
+python_version: null
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..0ae8910
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,42 @@
+---
+version: '3'
+services:
+ bionic:
+ container_name: bionic
+ image: naftulikay/bionic-vm:latest
+ privileged: true
+ volumes:
+ - /sys/fs/cgroup:/sys/fs/cgroup:ro
+ stop_grace_period: 1s
+
+ centos7:
+ container_name: centos7
+ image: naftulikay/centos7-vm:latest
+ privileged: true
+ volumes:
+ - /sys/fs/cgroup:/sys/fs/cgroup:ro
+ stop_grace_period: 1s
+
+ juno:
+ container_name: juno
+ image: naftulikay/juno-vm:latest
+ privileged: true
+ volumes:
+ - /sys/fs/cgroup:/sys/fs/cgroup:ro
+ stop_grace_period: 1s
+
+ loki:
+ container_name: loki
+ image: naftulikay/loki-vm:latest
+ privileged: true
+ volumes:
+ - /sys/fs/cgroup:/sys/fs/cgroup:ro
+ stop_grace_period: 1s
+
+ xenial:
+ container_name: xenial
+ image: naftulikay/xenial-vm:latest
+ privileged: true
+ volumes:
+ - /sys/fs/cgroup:/sys/fs/cgroup:ro
+ stop_grace_period: 1s
diff --git a/handlers/main.yml b/handlers/main.yml
deleted file mode 100644
index ed97d53..0000000
--- a/handlers/main.yml
+++ /dev/null
@@ -1 +0,0 @@
----
diff --git a/meta/main.yml b/meta/main.yml
index bb38924..10febf9 100644
--- a/meta/main.yml
+++ b/meta/main.yml
@@ -1,6 +1,7 @@
---
galaxy_info:
name: python-dev
+ src: naftulikay.python-dev
author: Naftuli Kay
description: Install and configure a Python development environment on a system.
@@ -15,3 +16,6 @@ galaxy_info:
versions: [trusty, xenial]
galaxy_tags: [python]
+
+dependencies:
+ - role: naftulikay.base
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..0b020d1
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,2 @@
+ansible
+git+https://github.com/naftulikay/travis-pls#egg=travis-pls
diff --git a/requirements.yml b/requirements.yml
index 46b7803..0fe4cbb 100644
--- a/requirements.yml
+++ b/requirements.yml
@@ -1,3 +1,5 @@
---
- src: naftulikay.vagrant-docker
name: vagrant-docker
+- src: naftulikay.vagrant-python-dev
+ name: vagrant-python-dev
\ No newline at end of file
diff --git a/tasks/discover/os.yml b/tasks/discover/os.yml
deleted file mode 100644
index 0202152..0000000
--- a/tasks/discover/os.yml
+++ /dev/null
@@ -1,17 +0,0 @@
----
-- name: establish operating system
- set_fact:
- os_name: |-
- {% if ansible_distribution|lower in ("redhat", "centos") -%}
- redhat
- {%- else -%}
- {{ ansible_distribution|lower }}
- {%- endif %}
-- name: establish operating system release
- set_fact:
- os_release: |-
- {% if os_name == "redhat" -%}
- rhel{{ ansible_distribution_major_version }}
- {%- else -%}
- {{ ansible_distribution_release | lower }}
- {%- endif %}
diff --git a/tasks/discover/python.yml b/tasks/include/00-facts.yml
similarity index 84%
rename from tasks/discover/python.yml
rename to tasks/include/00-facts.yml
index 7770089..dc2a527 100644
--- a/tasks/discover/python.yml
+++ b/tasks/include/00-facts.yml
@@ -1,4 +1,12 @@
---
+- name: load redhat variables
+ include_vars: redhat.yml
+ when: is_redhat_derivative
+
+- name: load ubuntu variables
+ include_vars: ubuntu.yml
+ when: is_ubuntu_derivative
+
- name: get python user details
command: getent passwd {{ python_user }}
become: true
@@ -49,4 +57,5 @@
python_detected_version: "{{ '' if python_version_check.rc > 0 else python_version_check.stdout.strip() }}"
- name: detect whether correct version of python
- set_fact: python_version_changed="{{ not python_detected_version.startswith(python_version) }}"
+ set_fact:
+ python_version_changed: "{{ not python_detected_version.startswith(python_version) }}"
diff --git a/tasks/include/10-apt-refresh.yml b/tasks/include/10-apt-refresh.yml
new file mode 100644
index 0000000..47be939
--- /dev/null
+++ b/tasks/include/10-apt-refresh.yml
@@ -0,0 +1,6 @@
+---
+- name: refresh apt cache
+ apt: update_cache=yes cache_valid_time=3600
+ when: is_ubuntu_derivative
+ become: true
+
diff --git a/tasks/include/20-packages.yml b/tasks/include/20-packages.yml
new file mode 100644
index 0000000..4e905f5
--- /dev/null
+++ b/tasks/include/20-packages.yml
@@ -0,0 +1,10 @@
+---
+- name: install epel
+ package: name=epel-release state=present
+ become: true
+ when: is_redhat_derivative
+
+- name: install python build dependencies
+ package: name={{ item }} state=present
+ with_items: "{{ python_build_packages }}"
+ become: true
diff --git a/tasks/pyenv.yml b/tasks/include/30-pyenv.yml
similarity index 57%
rename from tasks/pyenv.yml
rename to tasks/include/30-pyenv.yml
index 99e6f44..36dd612 100644
--- a/tasks/pyenv.yml
+++ b/tasks/include/30-pyenv.yml
@@ -1,16 +1,20 @@
---
-- name: download pyenv installer
- get_url:
+- name: fetch pyenv installer
+ uri:
url: https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer
- dest: "{{ pyenv_tmp_installer }}"
- mode: "0755"
+ method: GET
+ status_code: 200
+ return_content: true
+ register: pyenv_installer_response
when: not pyenv_installed
- name: install pyenv as the user
- command: "{{ pyenv_tmp_installer }} -y"
+ command: sh -s -- -y
+ args:
+ stdin: "{{ pyenv_installer_response.content }}"
become: true
become_user: "{{ python_user }}"
- when: not (pyenv_installed | bool)
+ when: not pyenv_installed
- name: install profile script
template:
@@ -19,6 +23,4 @@
owner: root
group: root
mode: "0755"
-
-- name: remove temp installer
- file: name="{{ pyenv_tmp_installer }}" state=absent
+ become: true
diff --git a/tasks/python.yml b/tasks/include/40-python.yml
similarity index 86%
rename from tasks/python.yml
rename to tasks/include/40-python.yml
index 09b0891..3c9a92d 100644
--- a/tasks/python.yml
+++ b/tasks/include/40-python.yml
@@ -12,4 +12,4 @@
become_user: "{{ python_user }}"
become_method: sudo
become_flags: -Hi
- when: python_version_changed or python_install_result|changed
+ when: python_version_changed or python_install_result is changed
diff --git a/tasks/main.yml b/tasks/main.yml
index ae30220..a6d1625 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -3,56 +3,17 @@
fail: msg="The python_user variable must be set."
when: (python_user is not defined) or (not python_user)
-# set facts to reliably determine os
-- name: discover operating system
- include_tasks: discover/os.yml
-
-# set facts to reliably determine python variables
-- name: discover python
- include_tasks: discover/python.yml
-
-# load per-os and per distro variables
-- name: load variables
- include_vars: "{{ var_loop_item }}"
- with_items:
- - "{{ os_name }}/common.yml"
- - "{{ os_name }}/{{ os_release }}.yml"
- loop_control: { loop_var: var_loop_item }
-
-# refresh cache on ubuntu
-- name: refresh apt cache
- apt: update_cache=yes cache_valid_time=3600
- when: os_name == "ubuntu"
-
-# install system python dependencies
-- name: install python build dependencies
- package: name={{ item }} state=present
- with_items: "{{ python_build_packages }}"
-
-# install pip egg dependencies
-- name: install python dev dependencies
- package: name={{ item }} state=present
- with_items: "{{ python_dev_packages.values() }}"
-
-# install pyenv
-- name: install pyenv
- include_tasks: pyenv.yml
-
-# install python
-- name: install python version
- include_tasks: python.yml
-
-# install additional dependencies
-- name: install additional python system packages
- package: name={{ item }} state=present
- with_items: "{{ addtl_python_system_packages }}"
-
-- name: install additional python system pip packages
- pip: name={{ item }} state=present
- with_items: "{{ addtl_python_pip_system_packages }}"
-
-- name: install additional python user pip packages
- pip: name={{ item }} executable="{{ python_user_home }}.pyenv/shims/pip" state=present
- with_items: "{{ addtl_python_pip_user_packages }}"
- become: true
- become_user: "{{ python_user }}"
+- name: fail when python version is not defined
+ fail: msg="The python_version variable must be set."
+ when: (python_version is not defined) or (not python_version)
+
+- name: execute tasks
+ include_tasks: "{{ include_task_item }}"
+ loop:
+ - include/00-facts.yml
+ - include/10-apt-refresh.yml
+ - include/20-packages.yml
+ - include/30-pyenv.yml
+ - include/40-python.yml
+ loop_control:
+ loop_var: include_task_item
diff --git a/templates/pyenv.sh.j2 b/templates/pyenv.sh.j2
index c635ad2..4266856 100644
--- a/templates/pyenv.sh.j2
+++ b/templates/pyenv.sh.j2
@@ -1,14 +1,34 @@
# set pyenv root
export PYENV_ROOT="$HOME/.pyenv"
-# add pyenv and friends to the path
-export PATH="$PYENV_ROOT/bin:$PATH"
-
-# source bash completions
-test -e "$PYENV_ROOT/completions/pyenv.bash" && \
- source "$PYENV_ROOT/completions/pyenv.bash"
+# source bash completions if we're in bash
+if [ "$(echo "$SHELL" | tr '/' '\n' | tail -1)" = "bash" ]; then
+ test -e "$PYENV_ROOT/completions/pyenv.bash" && \
+ . "$PYENV_ROOT/completions/pyenv.bash"
+fi
# initialize pyenv
if which pyenv >/dev/null 2>&1 ; then
eval "$(pyenv init -)"
fi
+
+__prepend_path() {
+ is_present=n
+
+ echo "$PATH" | tr ':' '\n' | while read path_component ; do
+ if [ "$path_component" = "$1" ]; then
+ is_present=y
+ break
+ fi
+ done
+
+ if [ "$is_present" = "n" ]; then
+ export PATH="$1:$PATH"
+ fi
+
+ unset is_present
+}
+
+__prepend_path "$PYENV_ROOT/shims"
+__prepend_path "$PYENV_ROOT/bin"
+unset __prepend_path
diff --git a/tests/Makefile b/tests/Makefile
new file mode 100644
index 0000000..c8504ee
--- /dev/null
+++ b/tests/Makefile
@@ -0,0 +1,13 @@
+#!/usr/bin/make -f
+
+galaxy:
+ @if [ -e requirements.yml ]; then \
+ ansible-galaxy install --force -r requirements.yml -p .ansible/galaxy-roles ; \
+ fi
+
+install: galaxy
+ @mkdir -p .ansible/roles
+ @rsync -a --exclude=tests/ ../ .ansible/roles/default/
+
+test: install
+ @ANSIBLE_FORCE_COLOR=yes ansible-playbook -i inventory/hosts.yml playbook.yml
\ No newline at end of file
diff --git a/tests/ansible.cfg b/tests/ansible.cfg
index 299caaf..9ef94a2 100644
--- a/tests/ansible.cfg
+++ b/tests/ansible.cfg
@@ -1,3 +1,3 @@
[defaults]
-roles_path = /etc/ansible/roles
retry_files_enabled = false
+roles_path = .ansible/roles:.ansible/galaxy-roles
\ No newline at end of file
diff --git a/tests/goss.d/commands.yml b/tests/goss.d/commands.yml
index 3a59d68..2b6fae6 100644
--- a/tests/goss.d/commands.yml
+++ b/tests/goss.d/commands.yml
@@ -1,7 +1,7 @@
---
command:
# executing pyenv version should return the specified python version
- 'sudo -Hiu {{.Env.python_user}} {{ .Env.pyenv_executable }} version':
+ 'sudo -Hu {{.Vars.python_user}} bash -l -c "pyenv version"':
exit-status: 0
stdout:
- - "{{.Env.python_version}}"
+ - "{{.Vars.python_version}}"
diff --git a/tests/goss.d/files.yml b/tests/goss.d/files.yml
index cfaafc9..8482d4f 100644
--- a/tests/goss.d/files.yml
+++ b/tests/goss.d/files.yml
@@ -6,14 +6,15 @@ file:
# check for pyenv root being set
- /export PYENV_ROOT=\"\$HOME/\.pyenv\"/
# check for path modifications
- - /export PATH=\"\$PYENV_ROOT/bin\:\$PATH\"/
+ - /\$PYENV_ROOT\/bin/
+ - /\$PYENV_ROOT\/shims/
# check for init
- /\$\(pyenv init \-\)/
- '/home/{{.Env.python_user}}/.pyenv':
+ '/home/{{.Vars.python_user}}/.pyenv':
exists: true
- '/home/{{.Env.python_user}}/.pyenv/version':
+ '/home/{{.Vars.python_user}}/.pyenv/version':
exists: true
contains:
- - "{{.Env.python_version}}"
+ - "{{.Vars.python_version}}"
diff --git a/tests/goss.d/packages.yml b/tests/goss.d/packages.yml
index 8f55af4..018051a 100644
--- a/tests/goss.d/packages.yml
+++ b/tests/goss.d/packages.yml
@@ -1,8 +1,4 @@
---
package:
- '{{.Env.libffi_package}}': { installed: true }
- '{{.Env.libxml2_package}}': { installed: true }
- '{{.Env.libxslt_package}}': { installed: true }
- '{{.Env.libyaml_package}}': { installed: true }
'git': { installed: true }
'patch': { installed: true }
diff --git a/tests/inventory/hosts.yml b/tests/inventory/hosts.yml
new file mode 100644
index 0000000..cc332fb
--- /dev/null
+++ b/tests/inventory/hosts.yml
@@ -0,0 +1,11 @@
+---
+all:
+ hosts:
+ bionic: {}
+ centos7: {}
+ juno: {}
+ loki: {}
+ xenial: {}
+
+ vars:
+ ansible_connection: docker
diff --git a/tests/playbook.yml b/tests/playbook.yml
index bee6b23..2be297a 100644
--- a/tests/playbook.yml
+++ b/tests/playbook.yml
@@ -1,33 +1,25 @@
---
-- name: setup
- hosts: localhost
- vars:
- container_user: vagrant
+- name: wait for boot
+ hosts: all
+ become: true
tasks:
- - name: create user
- user: name={{ container_user }} comment="Container User" shell=/bin/bash state=present
+ - name: await boot
+ command: wait-for-boot
+ changed_when: false
- name: build
- hosts: localhost
+ hosts: all
roles:
- - role: python-dev
- python_user: vagrant
- python_version: 2.7.13
+ - role: default
+ python_user: container
+ python_version: 3.7.2
- name: test
- hosts: localhost
- vars: {}
+ hosts: all
roles:
- - role: degoss
- degoss_debug: true
- degoss_clean: false
+ - role: naftulikay.degoss
goss_file: goss.yml
goss_addtl_dirs: [goss.d]
- goss_env_vars:
- libffi_package: "{{ python_dev_packages.libffi }}"
- libxml2_package: "{{ python_dev_packages.libxml2 }}"
- libxslt_package: "{{ python_dev_packages.libxslt }}"
- libyaml_package: "{{ python_dev_packages.libyaml }}"
- python_user: vagrant
- python_version: 2.7.13
- pyenv_executable: /home/vagrant/.pyenv/bin/pyenv
+ goss_variables:
+ python_user: container
+ python_version: 3.7.2
diff --git a/tests/requirements.yml b/tests/requirements.yml
index a98c495..2deb153 100644
--- a/tests/requirements.yml
+++ b/tests/requirements.yml
@@ -1,3 +1,3 @@
---
-- name: degoss
- src: naftulikay.degoss
+- src: naftulikay.base
+- src: naftulikay.degoss
\ No newline at end of file
diff --git a/vagrant.yml b/vagrant.yml
index 7e8a166..9defd7d 100644
--- a/vagrant.yml
+++ b/vagrant.yml
@@ -1,24 +1,8 @@
---
-- name: configure vagrant
+- name: build
hosts: all
become: true
- vars:
- role_name: python-dev
roles:
- role: vagrant-docker
-
- tasks:
- - name: be an adult
- selinux: state=enforcing policy=targeted
-
- - name: create ansible directories
- file: path={{ item }} state=directory owner=root group=root mode=0755
- with_items:
- - /etc/ansible/
- - /etc/ansible/roles
-
- - name: create symlinks
- file: src={{ item.src }} dest={{ item.dest }} state=link force=yes owner=root group=root
- with_items:
- - { src: "/vagrant", dest: "/etc/ansible/roles/{{ role_name }}" }
- - { src: "/vagrant/ansible.cfg", dest: "/etc/ansible/ansible.cfg" }
+ - role: vagrant-python-dev
+ python_version: 3.6.8
\ No newline at end of file
diff --git a/vars/main.yml b/vars/main.yml
deleted file mode 100644
index 6543249..0000000
--- a/vars/main.yml
+++ /dev/null
@@ -1,7 +0,0 @@
----
-python_version: "2.7.13"
-addtl_python_system_packages: []
-addtl_python_pip_system_packages: []
-addtl_python_pip_user_packages: []
-
-pyenv_tmp_installer: /tmp/pyenv
diff --git a/vars/redhat/common.yml b/vars/redhat.yml
similarity index 68%
rename from vars/redhat/common.yml
rename to vars/redhat.yml
index 1899029..447a13f 100644
--- a/vars/redhat/common.yml
+++ b/vars/redhat.yml
@@ -1,11 +1,4 @@
---
-# redhat/common.yml
-python_dev_packages:
- libffi: libffi-devel
- libxml2: libxml2-devel
- libxslt: libxslt-devel
- libyaml: libyaml-devel
-
python_build_packages:
# python build dependencies
- python
@@ -27,3 +20,7 @@ python_build_packages:
- xz-devel
- git
- patch
+ - libffi-devel
+ - libxml2-devel
+ - libxslt-devel
+ - libyaml-devel
diff --git a/vars/redhat/rhel7.yml b/vars/redhat/rhel7.yml
deleted file mode 100644
index ed97d53..0000000
--- a/vars/redhat/rhel7.yml
+++ /dev/null
@@ -1 +0,0 @@
----
diff --git a/vars/ubuntu/common.yml b/vars/ubuntu.yml
similarity index 73%
rename from vars/ubuntu/common.yml
rename to vars/ubuntu.yml
index 9be3d65..95e4dce 100644
--- a/vars/ubuntu/common.yml
+++ b/vars/ubuntu.yml
@@ -1,11 +1,4 @@
---
-# ubuntu/common.yml
-python_dev_packages:
- libffi: libffi-dev
- libxml2: libxml2-dev
- libxslt: libxslt1-dev
- libyaml: libyaml-dev
-
python_build_packages:
# python build dependencies
- python
@@ -30,3 +23,7 @@ python_build_packages:
- xz-utils
- tk-dev
- git
+ - libffi-dev
+ - libxml2-dev
+ - libxslt1-dev
+ - libyaml-dev
diff --git a/vars/ubuntu/trusty.yml b/vars/ubuntu/trusty.yml
deleted file mode 100644
index ed97d53..0000000
--- a/vars/ubuntu/trusty.yml
+++ /dev/null
@@ -1 +0,0 @@
----
diff --git a/vars/ubuntu/xenial.yml b/vars/ubuntu/xenial.yml
deleted file mode 100644
index ed97d53..0000000
--- a/vars/ubuntu/xenial.yml
+++ /dev/null
@@ -1 +0,0 @@
----