From 5640fffb6e464b1cf84a4275c29be626f49adf83 Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Fri, 26 May 2017 23:09:47 -0400 Subject: [PATCH] Initial commit. --- .gitignore | 2 ++ .travis.yml | 27 +++++++++++++++++++++++++++ LICENSE | 20 ++++++++++++++++++++ README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ defaults/main.yml | 2 ++ meta/main.yml | 29 +++++++++++++++++++++++++++++ tasks/main.yml | 9 +++++++++ tests/README.md | 11 +++++++++++ tests/test.yml | 10 ++++++++++ 9 files changed, 152 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 defaults/main.yml create mode 100644 meta/main.yml create mode 100644 tasks/main.yml create mode 100644 tests/README.md create mode 100644 tests/test.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c9b2377 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.retry +tests/test.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..3ce2d63 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,27 @@ +--- +services: docker + +env: + - distro: centos7 + - distro: fedora24 + - distro: ubuntu1604 + - distro: ubuntu1404 + - distro: debian8 + +script: + # Configure test script so we can run extra tests after playbook is run. + - export container_id=$(date +%s) + - export cleanup=false + + # Download test shim. + - wget -O ${PWD}/tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/ + - chmod +x ${PWD}/tests/test.sh + + # Run tests. + - ${PWD}/tests/test.sh + + # Test whether Docker is running correctly (Dockerception!). + - docker exec --tty ${container_id} docker run hello-world + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4275cf3 --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2017 Jeff Geerling + +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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..3649b46 --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ +# Ansible Role: Pip (for Python) + +[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-docker.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-docker) + +An Ansible Role that installs [Pip](https://pip.pypa.io) on Linux. + +## Requirements + +None. + +## Role Variables + +Available variables are listed below, along with default values (see `defaults/main.yml`): + + pip_install_packages: [] + +A list of packages to install with pip. Examples below: + + pip_install_packages: + # Specify a name and version. + - name: docker-py + version: 1.2.3 + # Or specify a package by itself. + - docker-py + +## Dependencies + +None. + +## Example Playbook + + - hosts: all + roles: + - geerlingguy.pip + +## License + +MIT / BSD + +## Author Information + +This role was created in 2017 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/). diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..5c07ee8 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,2 @@ +--- +pip_install_packages: [] diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..b5d427b --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,29 @@ +--- +dependencies: [] + +galaxy_info: + author: geerlingguy + description: Pip (Python package manager) for Linux. + issue_tracker_url: https://github.com/geerlingguy/ansible-role-pip/issues + company: "Midwestern Mac, LLC" + license: "license (BSD, MIT)" + min_ansible_version: 2.0 + platforms: + - name: EL + versions: + - all + - name: Fedora + versions: + - all + - name: Debian + versions: + - all + - name: Ubuntu + versions: + - all + galaxy_tags: + - system + - server + - packaging + - python + - tools \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..1743bad --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,9 @@ +--- +- name: Ensure Pip is installed. + package: name=python-pip state=present + +- name: Ensure pip_install_packages are installed. + pip: + name: "{{ item.name | default(item) }}" + version: "{{ item.version | default(omit) }}" + with_items: pip_install_packages diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..6fb2117 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,11 @@ +# Ansible Role tests + +To run the test playbook(s) in this directory: + + 1. Install and start Docker. + 1. Download the test shim (see .travis.yml file for the URL) into `tests/test.sh`: + - `wget -O tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/` + 1. Make the test shim executable: `chmod +x tests/test.sh`. + 1. Run (from the role root directory) `distro=[distro] playbook=[playbook] ./tests/test.sh` + +If you don't want the container to be automatically deleted after the test playbook is run, add the following environment variables: `cleanup=false container_id=$(date +%s)` diff --git a/tests/test.yml b/tests/test.yml new file mode 100644 index 0000000..0fec162 --- /dev/null +++ b/tests/test.yml @@ -0,0 +1,10 @@ +--- +- hosts: all + + pre_tasks: + - name: Update apt cache. + apt: update_cache=yes cache_valid_time=600 + when: ansible_os_family == 'Debian' + + roles: + - role_under_test