Refactor role to latest changes
Over the last 2 years we have learned a lot of things with ansible. Bump this role to be inline with others. This also import our role in to openstack-infra testing. Change-Id: I63f9c936fae40e536699cd612c0505e0f3a72d5d Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
parent
ec7a080931
commit
2aea7ee54c
@ -1,4 +1,4 @@
|
||||
[gerrit]
|
||||
host=review.openstack.org
|
||||
port=29418
|
||||
project=openstack/ansible-role-nodepool.git
|
||||
project=openstack/ansible-role-logrotate.git
|
||||
|
10
bindep.txt
Normal file
10
bindep.txt
Normal file
@ -0,0 +1,10 @@
|
||||
# This is a cross-platform list tracking distribution packages needed by tests;
|
||||
# see http://docs.openstack.org/infra/bindep/ for additional information.
|
||||
|
||||
git
|
||||
libffi-devel [platform:rpm]
|
||||
libffi-dev [platform:dpkg]
|
||||
libselinux-python [platform:rpm]
|
||||
libssl-dev [platform:dpkg]
|
||||
openssl-devel [platform:rpm]
|
||||
python2-dnf [platform:fedora]
|
@ -1,4 +1,4 @@
|
||||
# Copyright 2015 Red Hat, Inc.
|
||||
# Copyright 2017 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@ -12,6 +12,19 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
---
|
||||
|
||||
# tasks/main.yaml
|
||||
logrotate_task_manager:
|
||||
- install
|
||||
- config
|
||||
|
||||
# tasks/install.yaml
|
||||
logrotate_install_method: package
|
||||
|
||||
logrotate_package_name: logrotate
|
||||
logrotate_package_state: installed
|
||||
|
||||
# tasks/config.yaml
|
||||
logrotate_configs: []
|
||||
|
||||
logrotate_template_logrotate_config_dest: /etc/logrotate.d
|
||||
|
@ -1 +1 @@
|
||||
ansible
|
||||
ansible>=2.0.0
|
||||
|
@ -13,10 +13,11 @@
|
||||
# under the License.
|
||||
---
|
||||
- name: Template logrotate.d config files.
|
||||
become: yes
|
||||
template:
|
||||
dest: "{{ logrotate_template_logrotate_config_dest }}/{{ item.name }}"
|
||||
group: root
|
||||
mode: 0644
|
||||
owner: root
|
||||
src: "{{ logrotate_template_logrotate_config_src }}"
|
||||
with_items: logrotate_configs
|
||||
with_items: "{{ logrotate_configs }}"
|
||||
|
@ -12,8 +12,4 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
---
|
||||
- include: install/debian.yaml
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- include: install/redhat.yaml
|
||||
when: ansible_os_family == 'RedHat'
|
||||
- include: "install/{{ logrotate_install_method }}.yaml"
|
||||
|
@ -13,6 +13,7 @@
|
||||
# under the License.
|
||||
---
|
||||
- name: Ensure logrotate is installed.
|
||||
apt:
|
||||
pkg: logrotate
|
||||
state: installed
|
||||
become: yes
|
||||
package:
|
||||
name: "{{ logrotate_package_name }}"
|
||||
state: "{{ logrotate_package_state }}"
|
@ -1,18 +0,0 @@
|
||||
# Copyright 2015 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
---
|
||||
- name: Ensure logrotate is installed.
|
||||
yum:
|
||||
pkg: logrotate
|
||||
state: installed
|
@ -12,8 +12,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
---
|
||||
- include: install.yaml
|
||||
sudo: yes
|
||||
|
||||
- include: config.yaml
|
||||
sudo: yes
|
||||
- include: "{{ logrotate_task }}.yaml"
|
||||
with_items: "{{ logrotate_task_manager }}"
|
||||
loop_control:
|
||||
loop_var: logrotate_task
|
||||
|
@ -1,2 +1,2 @@
|
||||
[defaults]
|
||||
roles_path = ..
|
||||
roles_path = ../..
|
||||
|
@ -1,2 +1,2 @@
|
||||
[all]
|
||||
localhost ansible_connection=local
|
||||
localhost ansible_connection=ssh
|
||||
|
@ -13,12 +13,13 @@
|
||||
# under the License.
|
||||
---
|
||||
- hosts: localhost
|
||||
sudo: yes
|
||||
vars:
|
||||
rolename: "{{ lookup('pipe', 'pwd') | dirname | basename }}"
|
||||
|
||||
pre_tasks:
|
||||
# Make sure OS does not have a stale package cache.
|
||||
- name: Update apt cache.
|
||||
become: yes
|
||||
apt:
|
||||
update_cache: yes
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
40
tox.ini
40
tox.ini
@ -1,27 +1,19 @@
|
||||
[tox]
|
||||
minversion = 1.4.2
|
||||
envlist = ansible-lint,docs,pep8
|
||||
envlist = docs,linters
|
||||
skipsdist = True
|
||||
|
||||
[testenv]
|
||||
deps = -r{toxinidir}/requirements.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
|
||||
[testenv:ansible-lint]
|
||||
setenv =
|
||||
ANSIBLE_CONFIG = tests/ansible.cfg
|
||||
whitelist_externals = bash
|
||||
[testenv:functional]
|
||||
commands =
|
||||
bash -c "find . -type f -regex '.*.y[a]?ml' -print0 | xargs -t -n1 -0 \
|
||||
ansible-lint"
|
||||
bash -c "find tests -type f -regex '.*.y[a]?ml' -print | xargs -t -n1 \
|
||||
ansible-playbook --syntax-check -i tests/inventory \
|
||||
-e rolename=$(basename $(pwd)) > /dev/null"
|
||||
|
||||
[testenv:ansible-functional]
|
||||
commands =
|
||||
ansible-playbook -i tests/inventory tests/test.yaml
|
||||
passenv = HOME
|
||||
# NOTE(pabelanger): Because ansible default ansible_user to null now, we need to pass it via CLI.
|
||||
ansible-playbook -i tests/inventory tests/test.yaml -e ansible_user={env:USER}
|
||||
passenv =
|
||||
HOME
|
||||
USER
|
||||
setenv =
|
||||
ANSIBLE_CONFIG = {toxinidir}/tests/ansible.cfg
|
||||
PYTHONUNBUFFERED = 1
|
||||
@ -29,9 +21,6 @@ setenv =
|
||||
[testenv:docs]
|
||||
commands = python setup.py build_sphinx
|
||||
|
||||
[testenv:pep8]
|
||||
commands = flake8
|
||||
|
||||
[testenv:venv]
|
||||
commands = {posargs}
|
||||
|
||||
@ -42,3 +31,18 @@ show-source = True
|
||||
ignore = E123,E125
|
||||
builtins = _
|
||||
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build
|
||||
|
||||
[testenv:linters]
|
||||
setenv =
|
||||
ANSIBLE_CONFIG = tests/ansible.cfg
|
||||
whitelist_externals = bash
|
||||
commands =
|
||||
# PEP8 Lint Check
|
||||
flake8
|
||||
# Ansible Lint Check
|
||||
bash -c "find . -type f -regex '.*.y[a]?ml' -print0 | xargs -t -n1 -0 \
|
||||
ansible-lint"
|
||||
# Ansible Syntax Check
|
||||
bash -c "find tests -type f -regex '.*.y[a]?ml' -print | xargs -t -n1 \
|
||||
ansible-playbook --syntax-check -i tests/inventory \
|
||||
-e rolename=$(basename $(pwd)) > /dev/null"
|
||||
|
Loading…
Reference in New Issue
Block a user