--- /dev/null
+[all]
+ignore = .tox/**,
+ .git/**,
+ .gitignore,
+ .gitmodules,
+ .gitreview
+
+[all.Git]
+bears = GitCommitBear
+files = NONE
+ignore_length_regex = Signed-off-by,
+ Also-by,
+ Co-authored-by,
+ http://,
+ https://
+
--- /dev/null
+.molecule/
+.tox/
+__pycache__/
+*.pyc
+
--- /dev/null
+[gerrit]
+host=gerrit.linuxfoundation.org
+port=29418
+project=ansible/roles/haveged-install.git
+defaultbranch=master
--- /dev/null
+extends: default
+
+rules:
+ braces:
+ max-spaces-inside: 1
+ level: error
+ brackets:
+ max-spaces-inside: 1
+ level: error
+ line-length: disable
+ # NOTE(retr0h): Templates no longer fail this lint rule.
+ # Uncomment if running old Molecule templates.
+ # truthy: disable
--- /dev/null
+haveged-install
+===============
+
+Installs haveged to help systems with low entropy.
+
+Requirements
+------------
+
+None.
+
+Role Variables
+--------------
+
+None.
+
+Dependencies
+------------
+
+None.
+
+Example Playbook
+----------------
+
+
+ - hosts: servers
+ roles:
+ - { role: lfit.haveged-install }
+
+License
+-------
+
+MIT
+
+Author Information
+------------------
+
+Linux Foundation Release Engineering
--- /dev/null
+---
+# defaults file for haveged-install
--- /dev/null
+---
+# handlers file for haveged-install
--- /dev/null
+---
+galaxy_info:
+ author: Linux Foundation Release Engineering
+ description: Install haveged to help systems with low entropy.
+ company: The Linux Foundation
+ issue_tracker_url: https://jira.linuxfoundation.org
+
+ license: MIT
+
+ min_ansible_version: 1.2
+
+ # If this a Container Enabled role, provide the minimum Ansible Container version.
+ # min_ansible_container_version:
+
+ platforms:
+ - name: EL
+ versions:
+ - 7
+ - name: Ubuntu
+ versions:
+ - xenial
+
+ galaxy_tags:
+ - system
+
+dependencies: []
--- /dev/null
+#!/bin/bash
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2018 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+
+# If running in Jenkins we need to symlink the workspace so that
+# ansible can pick up the role.
+if [ ! -z "$JENKINS_URL" ]; then
+ ln -sf "$WORKSPACE" ../haveged-install
+fi
+
+molecule test --destroy=always
--- /dev/null
+# Molecule managed
+
+FROM {{ item.image }}
+
+RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
+ elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \
+ elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
+ elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \
+ elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; fi
--- /dev/null
+*******
+Install
+*******
+
+Requirements
+============
+
+* Docker Engine
+* docker-py
+
+Install
+=======
+
+.. code-block:: bash
+
+ $ sudo pip install docker-py
--- /dev/null
+---
+- name: Create
+ hosts: localhost
+ connection: local
+ gather_facts: false
+ no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
+ vars:
+ molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}"
+ molecule_ephemeral_directory: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}"
+ molecule_scenario_directory: "{{ lookup('env', 'MOLECULE_SCENARIO_DIRECTORY') }}"
+ molecule_yml: "{{ lookup('file', molecule_file) | molecule_from_yaml }}"
+ tasks:
+ - name: Create Dockerfiles from image names
+ template:
+ src: "{{ molecule_scenario_directory }}/Dockerfile.j2"
+ dest: "{{ molecule_ephemeral_directory }}/Dockerfile_{{ item.image | regex_replace('[^a-zA-Z0-9_]', '_') }}"
+ with_items: "{{ molecule_yml.platforms }}"
+ register: platforms
+
+ - name: Discover local Docker images
+ docker_image_facts:
+ name: "molecule_local/{{ item.item.name }}"
+ with_items: "{{ platforms.results }}"
+ register: docker_images
+
+ - name: Build an Ansible compatible image
+ docker_image:
+ path: "{{ molecule_ephemeral_directory }}"
+ name: "molecule_local/{{ item.item.image }}"
+ dockerfile: "{{ item.item.dockerfile | default(item.invocation.module_args.dest) }}"
+ force: "{{ item.item.force | default(true) }}"
+ with_items: "{{ platforms.results }}"
+ when: platforms.changed or docker_images.results | map(attribute='images') | select('equalto', []) | list | count >= 0
+
+ - name: Create molecule instance(s)
+ docker_container:
+ name: "{{ item.name }}"
+ hostname: "{{ item.name }}"
+ image: "molecule_local/{{ item.image }}"
+ state: started
+ recreate: false
+ log_driver: syslog
+ command: "{{ item.command | default('bash -c \"while true; do sleep 10000; done\"') }}"
+ privileged: "{{ item.privileged | default(omit) }}"
+ volumes: "{{ item.volumes | default(omit) }}"
+ capabilities: "{{ item.capabilities | default(omit) }}"
+ ports: "{{ item.exposed_ports | default(omit) }}"
+ register: server
+ with_items: "{{ molecule_yml.platforms }}"
+ async: 7200
+ poll: 0
+
+ - name: Wait for instance(s) creation to complete
+ async_status:
+ jid: "{{ item.ansible_job_id }}"
+ register: docker_jobs
+ until: docker_jobs.finished
+ retries: 300
+ with_items: "{{ server.results }}"
--- /dev/null
+---
+- name: Destroy
+ hosts: localhost
+ connection: local
+ gather_facts: false
+ no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
+ vars:
+ molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}"
+ molecule_yml: "{{ lookup('file', molecule_file) | molecule_from_yaml }}"
+ tasks:
+ - name: Destroy molecule instance(s)
+ docker_container:
+ name: "{{ item.name }}"
+ state: absent
+ force_kill: "{{ item.force_kill | default(true) }}"
+ register: server
+ with_items: "{{ molecule_yml.platforms }}"
+ async: 7200
+ poll: 0
+
+ - name: Wait for instance(s) deletion to complete
+ async_status:
+ jid: "{{ item.ansible_job_id }}"
+ register: docker_jobs
+ until: docker_jobs.finished
+ retries: 300
+ with_items: "{{ server.results }}"
--- /dev/null
+---
+dependency:
+ name: galaxy
+driver:
+ name: docker
+lint:
+ name: yamllint
+platforms:
+ - name: ubuntu1604
+ image: ubuntu:16.04
+provisioner:
+ name: ansible
+ lint:
+ name: ansible-lint
+scenario:
+ name: default
+verifier:
+ name: testinfra
+ lint:
+ name: flake8
--- /dev/null
+---
+- name: Converge
+ hosts: all
+ roles:
+ - role: haveged-install
--- /dev/null
+---
+- name: Prepare
+ hosts: all
+ gather_facts: false
+ tasks: []
--- /dev/null
+import os
+
+import testinfra.utils.ansible_runner
+
+testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
+ os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
+
+
+def test_hosts_file(host):
+ f = host.file('/etc/hosts')
+
+ assert f.exists
+ assert f.user == 'root'
+ assert f.group == 'root'
--- /dev/null
+---
+# tasks file for haveged-install
--- /dev/null
+localhost
+
--- /dev/null
+---
+- hosts: localhost
+ remote_user: root
+ roles:
+ - haveged-install
--- /dev/null
+[tox]
+minversion = 1.6
+envlist =
+ coala,
+ molecule
+skipsdist=true
+
+[testenv:coala]
+basepython = python3
+deps =
+ coala
+ coala-bears
+commands =
+ python3 -m nltk.downloader punkt maxent_treebank_pos_tagger averaged_perceptron_tagger
+ coala --non-interactive
+
+[testenv:molecule]
+basepython = python2
+deps =
+ ansible
+ docker-py
+ molecule
+passenv = *
+commands =
+ ./molecule.sh
--- /dev/null
+---
+# vars file for haveged-install