Skip to content

Commit

Permalink
Merge pull request #1 from Temelio/develop
Browse files Browse the repository at this point in the history
Update ansible, molecule env, role
  • Loading branch information
lmachetel authored Apr 19, 2019
2 parents aa1a662 + ecad062 commit 64596d4
Show file tree
Hide file tree
Showing 27 changed files with 348 additions and 142 deletions.
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Ansible
*.retry
roles/
tests/roles/

# Swap files
*.swo
*.swp

# Python bytecode
*.pyc

# Pytest
.cache
.pytest_cache

# Tox
.tox

# Vagrant
.vagrant
*.log

# Molecule
.molecule
5 changes: 5 additions & 0 deletions .pyup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---

# Pyup configuration

branch: 'develop'
41 changes: 17 additions & 24 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,27 @@

# Travis file for locales role

dist: 'xenial'
sudo: 'required'

language: python
python: "2.7"

before_install:
# Make sure everything's up to date.
- sudo apt-get update -qq
services:
- 'docker'

install:
# Install Ansible.
- pip install ansible
env:
matrix:
- TOXENV='py27-ansible24'
- TOXENV='py27-ansible25'
- TOXENV='py27-ansible26'
- TOXENV='py27-ansible27'

# Add ansible.cfg to pick up roles path.
- "cp ./tests/ansible.cfg ./"
install:
- 'pip install tox-travis'

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 --connection=local --sudo"

# Run the role/playbook again, checking to make sure it's idempotent.
# Set change=1 due to a bug in ansible service module always return changed
- >
ansible-playbook -i tests/inventory tests/test.yml --connection=local --sudo
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
# Check locales is accessible
- test "fr_FR.UTF-8" == `sudo cat /etc/default/locale | grep LANG= | cut -d '=' -f 2`
- 'tox -e "${TOXENV}"'

notifications:
webhooks: 'https://galaxy.ansible.com/api/v1/notifications/'
11 changes: 11 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
extends: default

rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
line-length: disable
truthy: disable
32 changes: 15 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
locales
=======

[![Build Status](https://travis-ci.org/infOpen/ansible-role-locales.svg?branch=master)](https://travis-ci.org/infOpen/ansible-role-locales)
[![License](https://img.shields.io/badge/license-MIT%20License-brightgreen.svg)](https://opensource.org/licenses/MIT)
[![Build Status](https://travis-ci.org/Temelio/ansible-role-locales.svg?branch=master)](https://travis-ci.com/Temelio/ansible-role-locales)
[![Build Status](https://travis-ci.org/Temelio/ansible-role-locales.svg?branch=develop)](https://travis-ci.com/Temelio/ansible-role-locales)
[![Updates](https://pyup.io/repos/github/Temelio/ansible-role-locales/shield.svg)](https://pyup.io/repos/github/Temelio/ansible-role-locales/)
[![Python 3](https://pyup.io/repos/github/Temelio/ansible-role-locales/python-3-shield.svg)](https://pyup.io/repos/github/Temelio/ansible-role-locales/)
[![Ansible Role](https://img.shields.io/ansible/role/.svg)](https://galaxy.ansible.com/Temelio/locales/)
[![GitHub tag](https://img.shields.io/github/tag/Temelio/ansible-role-locales.svg)](https://github.com/Temelio/ansible-role-locales/tags)

Install locales package.

Requirements
------------

This role requires Ansible 1.4 or higher, and platform requirements are listed
This role requires Ansible 2.4 or higher, and platform requirements are listed
in the metadata file.

Role Variables
Expand All @@ -18,32 +24,25 @@ Default role variables


locales_to_configure :
- "fr_FR.UTF-8 UTF-8"
- name: 'en_US.UTF-8 UTF-8'
state: 'present'

locales_default_lang : "fr_FR.UTF-8"
locales_default_lang : "eb_US.UTF-8"

locales_default_timezone : "Europe/Paris"

locales_config_file_owner : "root"
locales_config_file_group : "root"
locales_config_file_mode : "0644"

locales_gen_file_owner : "root"
locales_gen_file_group : "root"
locales_gen_file_mode : "0644"


# Default Debian vars

locales_packages :
- locales
- language-pack-fr
- language-pack-en (except for Stretch)

locales_config_file_dest : "/etc/default/locale"
locales_gen_file_dest : "/etc/locale.gen"


locales_update_command : "/usr/sbin/update-locale"


Dependencies
Expand All @@ -56,7 +55,7 @@ Example Playbook

- hosts: servers
roles:
- { role: achaussier.locales }
- { role: temelio.locales }

License
-------
Expand All @@ -66,6 +65,5 @@ MIT
Author Information
------------------

Alexandre Chaussier (for Infopen company)
- http://www.infopen.pro
- a.chaussier [at] infopen.pro
L Machetel (for Temelio company)
A Chaussier (for Infopen company)
19 changes: 9 additions & 10 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@

# Defaults file for locales

locales_to_configure :
- "fr_FR.UTF-8 UTF-8"
locales_to_configure:
- name: 'en_US.UTF-8 UTF-8'
state: 'present'

locales_default_lang : "fr_FR.UTF-8"
locales_default_lang: 'en_US.UTF-8'

locales_default_timezone : "Europe/Paris"
locales_default_timezone: "Europe/Paris"

locales_config_file_owner : "root"
locales_config_file_group : "root"
locales_config_file_mode : "0644"
locales_config_file_owner: "root"
locales_config_file_group: "root"
locales_config_file_mode: "0644"

locales_gen_file_owner : "root"
locales_gen_file_group : "root"
locales_gen_file_mode : "0644"
locales_packages: "{{ _locales_packages }}"
32 changes: 14 additions & 18 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
---
galaxy_info:
author: Alexandre Chaussier
description: install locales package
company: Infopen (http://www.infopen.pro)
license: MIT
min_ansible_version: 1.5
role_name: 'locales'
author: 'A Chaussier, L Machetel'
description: 'install locales package on Debian like systems'
company: 'Temelio (https://www.temelio.com)'
license: 'MIT'
min_ansible_version: '2.4'
platforms:
- name: Ubuntu
- name: 'Ubuntu'
versions:
- precise
- quantal
- saucy
- trusty
- utopic
- vivid
- name: Debian
- 'trusty'
- 'xenial'
- 'bionic'
- name: 'Debian'
versions:
- jessie
- wheezy

categories:
- system
- 'stretch'
galaxy_tags:
- 'system'
dependencies: []
14 changes: 14 additions & 0 deletions molecule/default/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Molecule managed

{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}

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; \
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi
16 changes: 16 additions & 0 deletions molecule/default/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
*******
Install
*******

Requirements
============

* Docker Engine
* docker-py

Install
=======

.. code-block:: bash
$ sudo pip install docker-py
47 changes: 47 additions & 0 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---

dependency:
name: 'galaxy'
driver:
name: 'docker'
lint:
name: 'yamllint'
platforms:
- name: "locales-docker-stretch"
image: 'minimum2scp/systemd-stretch'
command: '/sbin/init'
cap_add:
- 'SYS_PTRACE'
privileged: true
- name: "locales-docker-xenial"
image: 'solita/ubuntu-systemd:16.04'
command: '/sbin/init'
cap_add:
- 'SYS_PTRACE'
privileged: true
- name: "locales-docker-trusty"
image: 'ubuntu:trusty'
cap_add:
- 'SYS_PTRACE'
privileged: true
- name: "locales-docker-bionic"
image: 'solita/ubuntu-systemd:18.04'
command: '/sbin/init'
cap_add:
- 'SYS_PTRACE'
privileged: true
provisioner:
name: 'ansible'
lint:
name: 'ansible-lint'
host_vars: {}
scenario:
name: 'default'
verifier:
name: 'testinfra'
additional_files_or_dirs:
- '../../tests'
lint:
name: 'flake8'
options:
sudo: true
21 changes: 21 additions & 0 deletions molecule/default/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---

# Role tests

- name: 'Converge | Prerequisites tasks'
hosts: 'locales-docker-xenial'
gather_facts: false
tasks:
- name: 'PREREQUISITES | APT | Do an apt-get update'
become: true
raw: 'apt-get update -qq'
changed_when: false
- name: 'PREREQUISITES | APT | Install python 2.7'
become: true
raw: 'apt-get install -qq python2.7'
changed_when: false


- hosts: 'all'
roles:
- role: 'ansible-role-locales'
Binary file not shown.
21 changes: 21 additions & 0 deletions molecule/default/tests/test_installation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
Role tests
"""

import os
from testinfra.utils.ansible_runner import AnsibleRunner

testinfra_hosts = AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')


def test_hosts_file(host):
"""
Ensure /etc/default/locale file exists
"""

f = host.file('/etc/default/locale')

assert f.exists
assert f.user == 'root'
assert f.group == 'root'
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
docker==3.7.2
molecule==2.20.1
pytest==4.4.1
testinfra==2.1.0
tox==3.9.0
Loading

0 comments on commit 64596d4

Please sign in to comment.