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..f168ec1 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,80 @@ +--- +sudo: required +dist: trusty + +language: python +python: "2.7" + +env: + - ANSIBLE_VERSION=latest + - ANSIBLE_VERSION=2.2.0.0 + - 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 + - ANSIBLE_VERSION=1.9.5 + - ANSIBLE_VERSION=1.9.4 + - ANSIBLE_VERSION=1.9.3 + - ANSIBLE_VERSION=1.9.2 + - ANSIBLE_VERSION=1.9.1 + - ANSIBLE_VERSION=1.9.0.1 + - ANSIBLE_VERSION=1.8.4 + - ANSIBLE_VERSION=1.8.3 + - ANSIBLE_VERSION=1.8.2 + - ANSIBLE_VERSION=1.8.1 + - ANSIBLE_VERSION=1.8 + - ANSIBLE_VERSION=1.7.2 + - ANSIBLE_VERSION=1.7.1 + - ANSIBLE_VERSION=1.7 + - ANSIBLE_VERSION=1.6.9 + - ANSIBLE_VERSION=1.6.8 + - ANSIBLE_VERSION=1.6.7 + - ANSIBLE_VERSION=1.6.6 + - ANSIBLE_VERSION=1.6.5 + - ANSIBLE_VERSION=1.6.4 + - ANSIBLE_VERSION=1.6.3 + - ANSIBLE_VERSION=1.6.2 + - ANSIBLE_VERSION=1.6.10 + - ANSIBLE_VERSION=1.6.1 + - ANSIBLE_VERSION=1.6 + +branches: + only: + - master + +before_install: + - sudo apt-get update -qq + + # Remove haveged + - sudo apt-get remove --purge --yes haveged + +install: + # Install Ansible. + - if [ "$ANSIBLE_VERSION" = "latest" ]; then pip install --no-binary ansible ansible; else pip install --no-binary ansible ansible==$ANSIBLE_VERSION; 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) + +notifications: + email: false + hipchat: + rooms: + secure: K4TxXOa2nMT9L/hozL1P+CBSqIpVsohu0LA5H1cUGGIpKs1Fp/JBfjXfaWTlVV6cXFeK1sTAfwHGEtFzb5TkVFDonx/YT4rEJk1dBqkBUwcMZ9+1Pbz5xBfYhzgrx+yDnqSSsOwzYp9XuV7oR7lpiEBSXnjXR3/hNTJRMfAWzsknF+9+mBKWxm7EEGuzdboLkF6NCQvtBZRBM03EjUW3+WtlEsDx/6o7O2uVhuoXSJCYZ4XFmRxjjzWNEvbdKdhJxLXnT9m1MQDMO39tlo5/fACbNXf9fQKt7MZBtTRegQ3Rdu0lFJPchs/iusVyJ7i9QqFTg3P4AF5vjvWTkvO4Pa2eJubktnFp1Ga1EH/9yuZXU+mHINDIIeBSgGrfy2dM+APP8NjFmF04XVlQ0iHqJ1Tbwr2Cosvy84rv151EQ1hf9paZYvgpN/B6NTWXX4q8qSYMrgt67/qaUQZnZ/iRwFd2YYnpQVqZ47rVaJmrcVSpAyb8M+uSz6k2rTxtXnU3HFfLtkbXjyGxCX418cDr97QHNQi7emsA+ySPFd2lafFRT+cSW66wiyxQGih4XidWp6VoKgjAVGDZ3tn+bOu6pb1MZIcI3GsG9Thm3BdptFpBjcye3CK4yamtaHIrQChEipGeRdZ6xHbu/jo4Me8EP1sU3+tKQwrw1sK8j3gTkHk= + webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..069f6c4 --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +## haveged + +[![Build Status](https://travis-ci.org/Oefenweb/ansible-haveged.svg?branch=master)](https://travis-ci.org/Oefenweb/ansible-haveged) [![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-haveged-blue.svg)](https://galaxy.ansible.com/Oefenweb/haveged) + +Set up [haveged](https://www.digitalocean.com/community/tutorials/how-to-setup-additional-entropy-for-cloud-servers-using-haveged) in Debian-like systems. + +#### Requirements + +None + +#### Variables + +* `haveged_install`: [default: `[]`]: Additional packages to install + +* `haveged_daemon_args`: [default: `['-w 1024']`]: Options to pass to haveged + +## Dependencies + +None + +#### Example + +```yaml +--- +- hosts: all + roles: + - haveged +``` + +#### License + +MIT + +#### Author Information + +Mischa ter Smitten + +#### Feedback, bug-reports, requests, ... + +Are [welcome](https://github.com/Oefenweb/ansible-haveged/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..bfa21ae --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,6 @@ +# defaults file for haveged +--- +haveged_install: [] + +haveged_daemon_args: + - '-w 1024' diff --git a/files/empty b/files/empty new file mode 100644 index 0000000..e69de29 diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..b782e29 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,6 @@ +# handlers file for haveged +--- +- name: restart haveged + service: + name: haveged + state: restarted diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..b1fea00 --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,22 @@ +# meta file for haveged +--- +galaxy_info: + author: Mischa ter Smitten + company: Oefenweb.nl B.V. + description: Set up haveged in Debian-like systems + license: MIT + min_ansible_version: 1.6 + platforms: + - name: Ubuntu + versions: + - precise + - trusty + - xenial + - name: Debian + versions: + - wheezy + - jessie + galaxy_tags: + - system + - networking +dependencies: [] diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..de18528 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,35 @@ +# tasks file for haveged +--- +- 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: "{{ haveged_dependencies }}" + tags: + - configuration + - haveged + - haveged-dependencies + +- name: install additional + apt: + name: "{{ item }}" + state: "{{ apt_install_state | default('latest') }}" + with_items: "{{ haveged_install }}" + tags: + - configuration + - haveged + - haveged-install + +- name: update configuration file - /etc/default/haveged.conf + template: + src: etc/default/haveged.j2 + dest: /etc/default/haveged + owner: root + group: root + mode: 0644 + tags: + - configuration + - haveged + - haveged-configuration diff --git a/templates/etc/default/haveged.j2 b/templates/etc/default/haveged.j2 new file mode 100644 index 0000000..ca74392 --- /dev/null +++ b/templates/etc/default/haveged.j2 @@ -0,0 +1,3 @@ +# {{ ansible_managed }} + +DAEMON_ARGS="{{ haveged_daemon_args | join(' ') }}" 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/test.yml b/tests/test.yml new file mode 100644 index 0000000..1e82ac8 --- /dev/null +++ b/tests/test.yml @@ -0,0 +1,7 @@ +# test file for haveged +--- +- hosts: localhost + connection: local + sudo: true + roles: + - ../../ diff --git a/tests/vagrant.yml b/tests/vagrant.yml new file mode 100644 index 0000000..8e288f6 --- /dev/null +++ b/tests/vagrant.yml @@ -0,0 +1,7 @@ +# test file for haveged +--- +- hosts: all + remote_user: vagrant + sudo: true + roles: + - ../../ diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..1da4be6 --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,4 @@ +# vars file for haveged +--- +haveged_dependencies: + - haveged