diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f74c83a --- /dev/null +++ b/.gitignore @@ -0,0 +1,30 @@ +# OS generated files # +###################### +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +Icon? +ehthumbs.db +Thumbs.db + +# IDE files # +################# +/.settings +/.buildpath +/.project +/nbproject +*.komodoproject +*.kpf +/.idea + +# Vagrant files # +.virtualbox/ +.vagrant/ +vagrant_ansible_inventory_* +ansible.cfg + +# Other files # +############### +!empty diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..859a745 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,60 @@ +--- +sudo: required +dist: trusty + +language: python +python: "2.7" + +env: + - ANSIBLE_VERSION=latest + - ANSIBLE_VERSION=2.2.1.0 + - ANSIBLE_VERSION=2.2.0.0 + - ANSIBLE_VERSION=2.1.4 + - ANSIBLE_VERSION=2.1.3 + - ANSIBLE_VERSION=2.1.2 + - ANSIBLE_VERSION=2.1.1.0 + - ANSIBLE_VERSION=2.1.0.0 + - ANSIBLE_VERSION=2.0.2.0 + - ANSIBLE_VERSION=2.0.1.0 + - ANSIBLE_VERSION=2.0.0.2 + - ANSIBLE_VERSION=2.0.0.1 + - ANSIBLE_VERSION=2.0.0.0 + - ANSIBLE_VERSION=1.9.6 + +branches: + only: + - master + +before_install: + - sudo apt-get update -qq + + # Remove parallel + - sudo apt-get remove --purge --yes parallel || true + +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 || true; fi + +notifications: + email: false + hipchat: + rooms: + secure: Y546OvY1VE/YgT1o+IZYSVR3gO0t1rGVtRGO9/X++xi72y4s1kINnN3v4e2gc+8BAhHsueaqH4QGIHoJeTQ8+LcK9pNBRBmuxI4qzltcCXd5EV3iVuhhynE1IzixtRxYcps7U+T/VdSj/m80ZD4YvLmcD1pVAprCSUJcX8ccJQw3HZ1RuIyO2iIRmLjU6oc6Js+rDCZqie3yVLbRmVQL9O6LI15YWIpO4UPDcXHd26ugmUQTl/BRNaE0ROxVhu2R8OCKbC6ctrv04dog1+EZA3NMEX/L4HbN/7K6JlwC/5Cl840pc6Ned2NihGCkcejpae0UYrpr+BHgDfB/MBAXwqthutyAqtQvIiOV7KIgAJ9ID4+x+4RZYZYg3q5Y2vmGyILRPhzcverZrZTHuKvNxdQMBMs7Xi1/uL3//jrBoN0yD9JhC/hme0A6neGglQTFZWyEjU0T5pIeBJ4lAuG8EKN4WjzoD5LIr03PHO+037N+YjPYsIHMJr8UwaRL8YsBPvKGLyeAwOZnFFuyfUM8W0EIlrDkNVbUx+AS69oYCpUkxpynwZk3ssNZ3CK/yS2wXIfsEPdApk8tbS8FcvLGQvy+i+F5UedEWXgcXtYKuRJ2N2DnO6Z1kFgPcJQ70dDzaSLhXWf/+IUiR0wQHEjL4EtbhGd1kBL09CxjCwffJQI= + webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..9756e57 --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +## gnu-parallel + +[![Build Status](https://travis-ci.org/Oefenweb/ansible-gnu-parallel.svg?branch=master)](https://travis-ci.org/Oefenweb/ansible-gnu-parallel) [![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-gnu--parallel-blue.svg)](https://galaxy.ansible.com/Oefenweb/gnu-parallel) + +Set up the latest version of [GNU Parallel](https://www.gnu.org/software/parallel/) in Debian-like systems. + +#### Requirements + +None + +#### Variables + +* `gnu_parallel_remove_distro_version`: [default: `true`]: Whether or not to remove the distribution version + +## Dependencies + +None + +#### Example + +```yaml +--- +- hosts: all + roles: + - gnu-parallel +``` + +#### License + +MIT + +#### Author Information + +* Mischa ter Smitten + +#### Feedback, bug-reports, requests, ... + +Are [welcome](https://github.com/Oefenweb/ansible-gnu-parallel/issues)! diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..c2e3fe5 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,63 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby ts=2 sw=2 tw=0 et : + +role = File.basename(File.expand_path(File.dirname(__FILE__))) + +boxes = [ + { + :name => "ubuntu-1204", + :box => "bento/ubuntu-12.04", + :ip => '10.0.0.11', + :cpu => "50", + :ram => "256" + }, + { + :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', + :cpu => "50", + :ram => "256" + }, + { + :name => "debian-711", + :box => "bento/debian-7.11", + :ip => '10.0.0.14', + :cpu => "50", + :ram => "256" + }, + { + :name => "debian-86", + :box => "bento/debian-8.6", + :ip => '10.0.0.15', + :cpu => "50", + :ram => "256" + }, +] + +Vagrant.configure("2") do |config| + boxes.each do |box| + config.vm.define box[:name] do |vms| + vms.vm.box = box[:box] + vms.vm.hostname = "ansible-#{role}-#{box[:name]}" + + vms.vm.provider "virtualbox" do |v| + v.customize ["modifyvm", :id, "--cpuexecutioncap", box[:cpu]] + v.customize ["modifyvm", :id, "--memory", box[:ram]] + end + + vms.vm.network :private_network, ip: box[:ip] + + vms.vm.provision :ansible do |ansible| + ansible.playbook = "tests/vagrant.yml" + ansible.verbose = "vv" + end + end + end +end diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..23606e3 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,3 @@ +# defaults file for gnu-parallel +--- +gnu_parallel_remove_distro_version: true diff --git a/files/root/.parallel/will-cite b/files/root/.parallel/will-cite new file mode 100644 index 0000000..e69de29 diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..df793cf --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,2 @@ +# handlers file for gnu-parallel +--- diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..e5687d9 --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,22 @@ +# meta file for gnu-parallel +--- +galaxy_info: + author: Mischa ter Smitten + company: Oefenweb.nl B.V. + description: Set up the latest version of GNU Parallel in Debian-like systems + license: MIT + min_ansible_version: 1.9.6 + platforms: + - name: Ubuntu + versions: + - precise + - trusty + - xenial + - name: Debian + versions: + - wheezy + - jessie + galaxy_tags: + - shell + - system +dependencies: [] diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..401b3f4 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,136 @@ +# tasks file for gnu-parallel +--- +- name: install dependencies + apt: + name: "{{ item }}" + state: "{{ apt_install_state | default('latest') }}" + update_cache: true + cache_valid_time: "{{ apt_update_cache_valid_time | default(3600) }}" + with_items: "{{ gnu_parallel_dependencies }}" + tags: + - configuration + - gnu-parallel + - gnu-parallel-install + - gnu-parallel-install-dependencies + +- name: remove (distro version) + apt: + name: parallel + state: absent + purge: true + when: gnu_parallel_remove_distro_version + tags: + - configuration + - gnu-parallel + - gnu-parallel-remove + - gnu-parallel-remove-distro + +- name: create (download) directory + file: + path: "{{ gnu_parallel_download_path }}" + state: directory + owner: root + group: root + mode: 0755 + tags: + - configuration + - gnu-parallel + - gnu-parallel-install + - gnu-parallel-install-download + +- name: download (latest) + get_url: + url: "{{ gnu_parallel_download_url }}" + dest: "{{ gnu_parallel_download_path }}/{{ gnu_parallel_download_url | basename }}" + owner: root + group: root + mode: 0644 + force: true + tags: + - configuration + - gnu-parallel + - gnu-parallel-install + - gnu-parallel-install-download + +- name: create (build) directory + file: + path: "{{ gnu_parallel_build_path }}" + state: directory + owner: root + group: root + mode: 0755 + tags: + - configuration + - gnu-parallel + - gnu-parallel-install + - gnu-parallel-install-build + +- name: version check + shell: tar -jtf {{ gnu_parallel_download_path }}/{{ gnu_parallel_download_url | basename }} | head -n 1 + changed_when: false + register: _version_check + tags: + - configuration + - gnu-parallel + - gnu-parallel-install + - gnu-parallel-install-build + +- name: extract + unarchive: + src: "{{ gnu_parallel_download_path }}/{{ gnu_parallel_download_url | basename }}" + dest: "{{ gnu_parallel_build_path }}" + creates: "{{ gnu_parallel_build_path }}/{{ _version_check.stdout }}" + copy: false + register: _unarchive + tags: + - configuration + - gnu-parallel + - gnu-parallel-install + - gnu-parallel-install-build + +- name: configure + command: ./configure + args: + chdir: "{{ gnu_parallel_build_path }}/{{ _version_check.stdout }}" + when: _unarchive | changed + tags: + - configuration + - gnu-parallel + - gnu-parallel-install + - gnu-parallel-install-build + - gnu-parallel-install-build-configure + +- name: make + command: make -j{{ ansible_processor_cores + 1 }} + args: + chdir: "{{ gnu_parallel_build_path }}/{{ _version_check.stdout }}" + when: _unarchive | changed + tags: + - configuration + - gnu-parallel + - gnu-parallel-install + - gnu-parallel-install-build + - gnu-parallel-install-build-make + +- name: make install + command: make install + args: + chdir: "{{ gnu_parallel_build_path }}/{{ _version_check.stdout }}" + when: _unarchive | changed + tags: + - configuration + - gnu-parallel + - gnu-parallel-install + - gnu-parallel-install-build + - gnu-parallel-install-build-make-install + +- name: silence citation notice + copy: + src: root/.parallel + dest: "{{ ansible_env.HOME }}/" + owner: "{{ ansible_env.USER }}" + group: "{{ ansible_env.USER }}" + tags: + - configuration + - gnu-parallel + - gnu-parallel-silence-citation-notice diff --git a/templates/empty b/templates/empty new file mode 100644 index 0000000..e69de29 diff --git a/tests/inventory b/tests/inventory new file mode 100644 index 0000000..2fbb50c --- /dev/null +++ b/tests/inventory @@ -0,0 +1 @@ +localhost diff --git a/tests/post.yml b/tests/post.yml new file mode 100644 index 0000000..9b09b92 --- /dev/null +++ b/tests/post.yml @@ -0,0 +1,5 @@ +# post test file for gnu-parallel +--- +- name: post | test installation + command: parallel --version + changed_when: false diff --git a/tests/test.yml b/tests/test.yml new file mode 100644 index 0000000..0b053e4 --- /dev/null +++ b/tests/test.yml @@ -0,0 +1,9 @@ +# test file for gnu-parallel +--- +- hosts: localhost + connection: local + become: true + roles: + - ../../ + post_tasks: + - include: post.yml diff --git a/tests/vagrant.yml b/tests/vagrant.yml new file mode 100644 index 0000000..9cba743 --- /dev/null +++ b/tests/vagrant.yml @@ -0,0 +1,9 @@ +# test file for gnu-parallel +--- +- hosts: all + remote_user: vagrant + become: true + roles: + - ../../ + post_tasks: + - include: post.yml diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..83a5e32 --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,9 @@ +# vars file for gnu-parallel +--- +gnu_parallel_dependencies: + - build-essential + +gnu_parallel_build_path: /var/lib/ansible/gnu-parallel/build + +gnu_parallel_download_path: /var/lib/ansible/gnu-parallel/downloads +gnu_parallel_download_url: http://ftpmirror.gnu.org/parallel/parallel-latest.tar.bz2