Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
257 additions
and
327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
# python | ||
*.pyc | ||
*.pyo | ||
__pycache__ | ||
# Ansible | ||
.ansible/galaxy-roles | ||
.ansible/roles | ||
*.retry | ||
|
||
# vagrant | ||
/.ansible | ||
/.vagrant | ||
tests/.ansible/ | ||
|
||
# Vagrant | ||
.vagrant/ | ||
*-VBoxSVC-*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
<dl> | ||
<dt><code>python_user</code></dt> | ||
<dd>User to install Python tools for. Required.</dd> | ||
<dt><code>python_version</code></dt> | ||
<dd>Version of Python to install. Defaults to 2.7.</dd> | ||
<dt><code>addtl_python_system_packages</code></dt> | ||
<dd>A list of additional system packages to install.</dd> | ||
<dt><code>addtl_python_pip_system_packages</code></dt> | ||
<dd>A list of additional Python system packages to install via pip.</dd> | ||
<dt><code>addtl_python_pip_user_packages</code></dt> | ||
<dd>A list of additional Python user packages to install via pip.</dd> | ||
<dl> | ||
|
||
## 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
--- | ||
python_user: null | ||
python_version: null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ansible | ||
git+https://github.com/naftulikay/travis-pls#egg=travis-pls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
--- | ||
- src: naftulikay.vagrant-docker | ||
name: vagrant-docker | ||
- src: naftulikay.vagrant-python-dev | ||
name: vagrant-python-dev |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
- name: refresh apt cache | ||
apt: update_cache=yes cache_valid_time=3600 | ||
when: is_ubuntu_derivative | ||
become: true | ||
|
Oops, something went wrong.