Remove json_error callback

This change removes the json_error callback plugin. This plugin does not work, as seen in the
logs:

    [WARNING]: Failure using method (v2_playbook_on_stats) in callback plugin (<ans
    ible.plugins.callback./usr/share/ansible/plugins/callback/json_error.CallbackMo
    dule object at 0x7f6ee2270dd0>): [Errno 13] Permission denied: 'ansible-
    errors.json'

Given this plugin has no value, due to it being broken for a long time, we're removing it which
will stop the warning being raised in our ansible output.

* The test_json_error_callback role has also been removed, given this no longer serves any purpose.
* The molecule test layout has been updated so that we're no longer running this test.

Change-Id: I76cd51df4ff26b22f3d9b590ceded848581d4c3d
Signed-off-by: Kevin Carter <kecarter@redhat.com>
changes/13/706313/2
Kevin Carter 3 years ago
parent 769ecb6a20
commit 6fd612c8fb
No known key found for this signature in database
GPG Key ID: CE94BD890A47B20A

@ -1,13 +0,0 @@
===================
Module - json_error
===================
This module provides for the following ansible plugin:
* json_error
.. ansibleautoplugin::
:module: tripleo_ansible/ansible_plugins/callback/json_error.py
:documentation: true

@ -1,6 +0,0 @@
===============================
Role - test_json_error_callback
===============================
.. ansibleautoplugin::
:role: tripleo_ansible/roles/test_json_error_callback

@ -1,59 +0,0 @@
# Copyright 2018 Red Hat, Inc.
# All Rights Reserved.
#
# 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.
# Ansible has another callback plugin just called "json.py", which overrides
# a normal import of "import json", so use absolute imports
from __future__ import absolute_import
import json
import os
from ansible.plugins.callback import CallbackBase
DOCUMENTATION = '''
callback: json_error
short_description: Write errors in JSON format to a log file
description:
- This callback writes errors in JSON format to a log file
type: aggregate
options:
output_dir:
name: json-error log file
default: ansible-error.json
description: Log file where to write errors in JSON format.
env:
- name: JSON_ERROR_LOG_FILE
'''
class CallbackModule(CallbackBase):
CALLBACK_VERSION = 2.5
CALLBACK_TYPE = 'aggregate'
CALLBACK_NAME = 'json-error'
def __init__(self, display=None):
super(CallbackModule, self).__init__(display)
self.errors = {}
self.log_file = os.getenv(
'JSON_ERROR_LOG_FILE', 'ansible-errors.json')
def v2_playbook_on_stats(self, stats):
with open(self.log_file, 'w') as f:
f.write(json.dumps(self.errors))
def v2_runner_on_failed(self, result, ignore_errors=False):
if not ignore_errors:
host_errors = self.errors.setdefault(result._host.name, [])
host_errors.append((result.task_name, result._result))

@ -1,44 +0,0 @@
---
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# 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.
galaxy_info:
author: OpenStack
description: TripleO OpenStack Role -- test_json_error_callback
company: Red Hat
license: Apache-2.0
min_ansible_version: 2.7
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
platforms:
- name: Fedora
versions:
- 28
- name: CentOS
versions:
- 7
galaxy_tags:
- tripleo
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies: []

@ -1,37 +0,0 @@
# Molecule managed
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# 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.
{% 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 install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install sudo python*-devel python*-dnf bash {{ item.pkg_extras | default('') }} && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl python-setuptools bash {{ item.pkg_extras | default('') }} && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml {{ item.pkg_extras | default('') }} && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates {{ item.pkg_extras | default('') }}; \
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates {{ item.pkg_extras | default('') }} && xbps-remove -O; fi
{% for pkg in item.easy_install | default([]) %}
# install pip for centos where there is no python-pip rpm in default repos
RUN easy_install {{ pkg }}
{% endfor %}
CMD ["sh", "-c", "while true; do sleep 10000; done"]

@ -1,56 +0,0 @@
---
driver:
name: docker
log: true
platforms:
- name: centos7
hostname: centos7
image: centos:7
dockerfile: Dockerfile
pkg_extras: python-setuptools
easy_install:
- pip
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
volumes:
- /tmp:/tmp
- name: centos8
hostname: centos8
image: centos:8
dockerfile: Dockerfile
pkg_extras: python*-setuptools
environment:
<<: *env
volumes:
- /tmp:/tmp
provisioner:
name: ansible
config_options:
defaults:
callback_whitelist: json_error
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
JSON_ERROR_LOG_FILE: /tmp/json_error.log
scenario:
test_sequence:
- destroy
- create
- prepare
- converge
- verify
- destroy
lint:
enabled: false
verifier:
name: testinfra
lint:
name: flake8

@ -1,21 +0,0 @@
---
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# 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: Converge
hosts: all
roles:
- role: "test_json_error_callback"

@ -1,21 +0,0 @@
---
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# 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: Prepare
hosts: all
roles:
- role: test_deps

@ -1,27 +0,0 @@
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# 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.
import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
def test_for_logfile(host):
assert host.file("/tmp/json_error.log").exists

@ -1,22 +0,0 @@
---
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# 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: Force error
package:
name: bison
state: notastate
ignore_errors: true

@ -6,7 +6,6 @@
- tripleo-ansible-centos-7-molecule-backup_and_restore
- tripleo-ansible-centos-7-molecule-login_defs
- tripleo-ansible-centos-7-molecule-test_deps
- tripleo-ansible-centos-7-molecule-test_json_error_callback
- tripleo-ansible-centos-7-molecule-test_package_action
- tripleo-ansible-centos-7-molecule-tripleo_bootstrap
- tripleo-ansible-centos-7-molecule-tripleo_cellv2
@ -50,7 +49,6 @@
- tripleo-ansible-centos-7-molecule-backup_and_restore
- tripleo-ansible-centos-7-molecule-login_defs
- tripleo-ansible-centos-7-molecule-test_deps
- tripleo-ansible-centos-7-molecule-test_json_error_callback
- tripleo-ansible-centos-7-molecule-test_package_action
- tripleo-ansible-centos-7-molecule-tripleo_bootstrap
- tripleo-ansible-centos-7-molecule-tripleo_cellv2
@ -118,13 +116,6 @@
parent: tripleo-ansible-centos-7-base
vars:
tripleo_role_name: test_deps
- job:
files:
- ^tripleo_ansible/roles/test_json_error_callback/.*
name: tripleo-ansible-centos-7-molecule-test_json_error_callback
parent: tripleo-ansible-centos-7-base
vars:
tripleo_role_name: test_json_error_callback
- job:
files:
- ^tripleo_ansible/ansible_plugins/action/package.py

Loading…
Cancel
Save