Update tox.ini with Ansible linting and Browbeat config linting
This commit enanbles Ansible linting and does some minor refactoring to make existing Ansible roles compatible with the new rules. Several Ansible linting rules have been excluded to keep the number of changes from being too onerous. Also a new script in ci-scripts is used to check very config file included in the Browbeat repo for validity using the template Browbeat uses when it runs. Here's a list of the new linting rules * Ansible tasks must have names * When you use shell you must use become not sudo * Using become_user without using become is not allowed * If a repo is pulled it must be a pinned version of commit, not latest * Always_run is deprecated don't use it * Variables without {{}} and not in when statements are deprecated don't use them * No Trailing whitepaces * YAML checking, catches big syntax errors but not less obvious ones Change-Id: Ic531c91c408996d4e7d8899afe8b21d364998680
This commit is contained in:
parent
a78dd877be
commit
c60b55ec83
@ -57,10 +57,15 @@
|
|||||||
ansible_python_interpreter: "/usr/bin/python"
|
ansible_python_interpreter: "/usr/bin/python"
|
||||||
name: Generating bug report
|
name: Generating bug report
|
||||||
tasks:
|
tasks:
|
||||||
- file: "path={{result_dir}} state=directory"
|
- name: Create results dir
|
||||||
- template: src=templates/bug_report.j2 dest={{result_dir}}/bug_report.log
|
file: "path={{result_dir}} state=directory"
|
||||||
|
- name: Template Bug report
|
||||||
|
template: src=templates/bug_report.j2 dest={{result_dir}}/bug_report.log
|
||||||
become: false
|
become: false
|
||||||
- template: src=templates/mysql_report.j2 dest={{result_dir}}/mysql_report.log
|
- name: Template MySQL report
|
||||||
|
template: src=templates/mysql_report.j2 dest={{result_dir}}/mysql_report.log
|
||||||
become: false
|
become: false
|
||||||
- replace: dest={{result_dir}}/mysql_report.log regexp='\[([^\s+]+)' replace=''
|
- name: Run MySQL report regex
|
||||||
- replace: dest={{result_dir}}/mysql_report.log regexp='\r' replace=''
|
replace: dest={{result_dir}}/mysql_report.log regexp='\[([^\s+]+)' replace=''
|
||||||
|
- name: Run MySQL report regex
|
||||||
|
replace: dest={{result_dir}}/mysql_report.log regexp='\r' replace=''
|
||||||
|
3
ansible/install/roles/grafana_docker/handlers/main.yml
Normal file
3
ansible/install/roles/grafana_docker/handlers/main.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
- name: restart systemd-grafana
|
||||||
|
shell: /usr/bin/systemctl daemon-reload && /usr/bin/systemctl enable grafana-server && /usr/bin/systemctl restart grafana-server
|
||||||
|
become: true
|
@ -65,10 +65,6 @@
|
|||||||
group=root
|
group=root
|
||||||
mode=0644
|
mode=0644
|
||||||
become: true
|
become: true
|
||||||
register: systemd_grafana_needs_restart
|
notify: restart systemd-grafana
|
||||||
|
|
||||||
- name: bounce systemd and grafana-server container
|
|
||||||
shell: /usr/bin/systemctl daemon-reload && /usr/bin/systemctl enable grafana-server && /usr/bin/systemctl restart grafana-server
|
|
||||||
become: true
|
|
||||||
when: systemd_grafana_needs_restart.changed
|
|
||||||
|
|
||||||
|
6
ansible/install/roles/graphite/handlers/main.yml
Normal file
6
ansible/install/roles/graphite/handlers/main.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
- name: restart apache
|
||||||
|
service: name=httpd state=restarted enabled=true
|
||||||
|
become: true
|
||||||
|
- name: restart carbon-cache
|
||||||
|
service: name=carbon-cache state=restarted enabled=true
|
||||||
|
become: true
|
@ -29,7 +29,8 @@
|
|||||||
shell: /root/setup-graphite-db.exp {{ graphite_username }} {{ graphite_password }} && chown apache:apache /var/lib/graphite-web/graphite.db
|
shell: /root/setup-graphite-db.exp {{ graphite_username }} {{ graphite_password }} && chown apache:apache /var/lib/graphite-web/graphite.db
|
||||||
become: true
|
become: true
|
||||||
when: graphite_db_installed.rc != 0
|
when: graphite_db_installed.rc != 0
|
||||||
register: apache_needs_restart
|
notify:
|
||||||
|
- restart apache
|
||||||
|
|
||||||
- name: Setup httpd graphite-web config
|
- name: Setup httpd graphite-web config
|
||||||
template:
|
template:
|
||||||
@ -39,7 +40,8 @@
|
|||||||
group=root
|
group=root
|
||||||
mode=0644
|
mode=0644
|
||||||
become: true
|
become: true
|
||||||
register: apache_needs_restart
|
notify:
|
||||||
|
- restart apache
|
||||||
|
|
||||||
### begin firewall ###
|
### begin firewall ###
|
||||||
# we need TCP/80 open
|
# we need TCP/80 open
|
||||||
@ -110,12 +112,8 @@
|
|||||||
- name: Remove httpd welcome config
|
- name: Remove httpd welcome config
|
||||||
become: true
|
become: true
|
||||||
file: path=/etc/httpd/conf.d/welcome.conf state=absent
|
file: path=/etc/httpd/conf.d/welcome.conf state=absent
|
||||||
register: apache_needs_restart
|
notify:
|
||||||
|
- restart apache
|
||||||
- name: Bounce Apache
|
|
||||||
service: name=httpd state=restarted enabled=true
|
|
||||||
become: true
|
|
||||||
when: apache_needs_restart.changed
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# setup the python-carbon service
|
# setup the python-carbon service
|
||||||
@ -133,7 +131,8 @@
|
|||||||
group=root
|
group=root
|
||||||
mode=0644
|
mode=0644
|
||||||
become: true
|
become: true
|
||||||
register: carbon_cache_needs_restart
|
notify:
|
||||||
|
- restart carbon-cache
|
||||||
|
|
||||||
- name: copy carbon storage aggregation config
|
- name: copy carbon storage aggregation config
|
||||||
copy:
|
copy:
|
||||||
@ -143,7 +142,8 @@
|
|||||||
group=root
|
group=root
|
||||||
mode=0644
|
mode=0644
|
||||||
become: true
|
become: true
|
||||||
register: carbon_cache_needs_restart
|
notify:
|
||||||
|
- restart carbon-cache
|
||||||
|
|
||||||
- name: copy carbon config
|
- name: copy carbon config
|
||||||
copy:
|
copy:
|
||||||
@ -153,10 +153,7 @@
|
|||||||
group=root
|
group=root
|
||||||
mode=0644
|
mode=0644
|
||||||
become: true
|
become: true
|
||||||
register: carbon_cache_needs_restart
|
notify:
|
||||||
|
- restart carbon-cache
|
||||||
|
|
||||||
- name: bounce carbon cache
|
|
||||||
service: name=carbon-cache state=restarted enabled=true
|
|
||||||
become: true
|
|
||||||
when: carbon_cache_needs_restart.changed
|
|
||||||
|
|
||||||
|
3
ansible/install/roles/graphite_docker/handlers/main.yml
Normal file
3
ansible/install/roles/graphite_docker/handlers/main.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
- name: restart systemd-graphite
|
||||||
|
shell: /usr/bin/systemctl daemon-reload && /usr/bin/systemctl enable graphite-web && /usr/bin/systemctl restart graphite-web
|
||||||
|
become: true
|
@ -87,12 +87,8 @@
|
|||||||
group=root
|
group=root
|
||||||
mode=0644
|
mode=0644
|
||||||
become: true
|
become: true
|
||||||
register: systemd_graphite_needs_restart
|
notify: restart systemd-graphite
|
||||||
|
|
||||||
- name: bounce systemd and graphite-web container
|
|
||||||
shell: /usr/bin/systemctl daemon-reload && /usr/bin/systemctl enable graphite-web && /usr/bin/systemctl restart graphite-web
|
|
||||||
become: true
|
|
||||||
when: systemd_graphite_needs_restart.changed
|
|
||||||
|
|
||||||
- name: Setup carbon-cache systemd config
|
- name: Setup carbon-cache systemd config
|
||||||
template:
|
template:
|
||||||
@ -102,10 +98,6 @@
|
|||||||
group=root
|
group=root
|
||||||
mode=0644
|
mode=0644
|
||||||
become: true
|
become: true
|
||||||
register: systemd_carbon_needs_restart
|
notify: restart systemd-graphite
|
||||||
|
|
||||||
- name: bounce systemd and carbon-cache container
|
|
||||||
shell: /usr/bin/systemctl daemon-reload && /usr/bin/systemctl enable carbon-cache && /usr/bin/systemctl restart carbon-cache
|
|
||||||
become: true
|
|
||||||
when: systemd_carbon_needs_restart.changed
|
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ browbeat:
|
|||||||
cloud_name: openstack
|
cloud_name: openstack
|
||||||
elasticsearch:
|
elasticsearch:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
regather: false
|
||||||
host: 1.1.1.1
|
host: 1.1.1.1
|
||||||
port: 9200
|
port: 9200
|
||||||
metadata_files:
|
metadata_files:
|
||||||
|
27
ci-scripts/linters/lint-browbeat-config.py
Normal file
27
ci-scripts/linters/lint-browbeat-config.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# 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 yaml
|
||||||
|
import sys
|
||||||
|
from pykwalify import core as pykwalify_core
|
||||||
|
from pykwalify import errors as pykwalify_errors
|
||||||
|
stream = open(sys.argv[1], 'r')
|
||||||
|
schema = yaml.load(stream)
|
||||||
|
check = pykwalify_core.Core(sys.argv[2], schema_data=schema)
|
||||||
|
try:
|
||||||
|
check.validate(raise_exception=True)
|
||||||
|
print ("Validation successful")
|
||||||
|
exit(0)
|
||||||
|
except pykwalify_errors.SchemaError as e:
|
||||||
|
print ("Config " + sys.argv[2] + " is not valid!")
|
||||||
|
raise Exception('File does not conform to schema: {}'.format(e))
|
@ -5,6 +5,7 @@ browbeat:
|
|||||||
cloud_name: openstack
|
cloud_name: openstack
|
||||||
elasticsearch:
|
elasticsearch:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
regather: false
|
||||||
host: 1.1.1.1
|
host: 1.1.1.1
|
||||||
port: 9200
|
port: 9200
|
||||||
metadata_files:
|
metadata_files:
|
||||||
|
@ -6,6 +6,7 @@ browbeat:
|
|||||||
cloud_name: openstack
|
cloud_name: openstack
|
||||||
elasticsearch:
|
elasticsearch:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
regather: false
|
||||||
host: 1.1.1.1
|
host: 1.1.1.1
|
||||||
port: 9200
|
port: 9200
|
||||||
regather: true
|
regather: true
|
||||||
|
@ -6,6 +6,7 @@ browbeat:
|
|||||||
cloud_name: openstack
|
cloud_name: openstack
|
||||||
elasticsearch:
|
elasticsearch:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
regather: false
|
||||||
host: 1.1.1.1
|
host: 1.1.1.1
|
||||||
port: 9200
|
port: 9200
|
||||||
regather: true
|
regather: true
|
||||||
|
@ -5,6 +5,7 @@ browbeat:
|
|||||||
cloud_name: openstack
|
cloud_name: openstack
|
||||||
elasticsearch:
|
elasticsearch:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
regather: false
|
||||||
host: 1.1.1.1
|
host: 1.1.1.1
|
||||||
port: 9200
|
port: 9200
|
||||||
metadata_files:
|
metadata_files:
|
||||||
|
@ -8,6 +8,7 @@ browbeat:
|
|||||||
cloud_name: openstack
|
cloud_name: openstack
|
||||||
elasticsearch:
|
elasticsearch:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
regather: false
|
||||||
host: 1.1.1.1
|
host: 1.1.1.1
|
||||||
port: 9200
|
port: 9200
|
||||||
metadata_files:
|
metadata_files:
|
||||||
|
@ -10,6 +10,7 @@ browbeat:
|
|||||||
cloud_name: openstack
|
cloud_name: openstack
|
||||||
elasticsearch:
|
elasticsearch:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
regather: false
|
||||||
host: 1.1.1.1
|
host: 1.1.1.1
|
||||||
port: 9200
|
port: 9200
|
||||||
metadata_files:
|
metadata_files:
|
||||||
|
@ -9,6 +9,7 @@ browbeat:
|
|||||||
cloud_name: openstack
|
cloud_name: openstack
|
||||||
elasticsearch:
|
elasticsearch:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
regather: false
|
||||||
host: 1.1.1.1
|
host: 1.1.1.1
|
||||||
port: 9200
|
port: 9200
|
||||||
regather: true
|
regather: true
|
||||||
|
15
tox.ini
15
tox.ini
@ -1,7 +1,6 @@
|
|||||||
[tox]
|
[tox]
|
||||||
minversion = 2.0
|
minversion = 2.0
|
||||||
#envlist = py34-constraints,py27-constraints,pypy-constraints,pep8-constraints
|
envlist = py27-constraints,pep8-constraints,linters
|
||||||
envlist = py27-constraints,pypy-constraints,pep8-constraints
|
|
||||||
skipsdist = True
|
skipsdist = True
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
@ -13,17 +12,23 @@ setenv =
|
|||||||
VIRTUAL_ENV={envdir}
|
VIRTUAL_ENV={envdir}
|
||||||
deps = -r{toxinidir}/test-requirements.txt
|
deps = -r{toxinidir}/test-requirements.txt
|
||||||
commands = python setup.py test
|
commands = python setup.py test
|
||||||
#commands = python setup.py test --slowest --testr-args='{posargs}'
|
|
||||||
|
|
||||||
[testenv:common-constraints]
|
[testenv:common-constraints]
|
||||||
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}
|
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}
|
||||||
|
|
||||||
|
|
||||||
[testenv:linters]
|
[testenv:linters]
|
||||||
whitelist_externals = bash
|
whitelist_externals = bash
|
||||||
commands =
|
commands =
|
||||||
|
pip install pykwalify
|
||||||
flake8
|
flake8
|
||||||
# bash -c "cd ansible; find . -type f -regex '.*.y[a]?ml' -print0 | xargs -t -n1 -0 \
|
bash -c "cd ansible; find . -type f -regex '.*.y[a]?ml' -print0 | xargs -t -n1 -0 \
|
||||||
# ansible-lint"
|
ansible-lint \
|
||||||
|
-x ANSIBLE0013,ANSIBLE0012,ANSIBLE0006,ANSIBLE0007,ANSIBLE0010,ANSIBLE0016"
|
||||||
|
python ci-scripts/linters/lint-browbeat-config.py lib/validate.yaml browbeat-config.yaml
|
||||||
|
python ci-scripts/linters/lint-browbeat-config.py lib/validate.yaml browbeat-complete.yaml
|
||||||
|
bash -c "for config in $(ls conf/); do \
|
||||||
|
python ci-scripts/linters/lint-browbeat-config.py lib/validate.yaml conf/$config; done"
|
||||||
|
|
||||||
[testenv:pep8]
|
[testenv:pep8]
|
||||||
commands = flake8 {posargs} --exclude=ansible
|
commands = flake8 {posargs} --exclude=ansible
|
||||||
|
Loading…
Reference in New Issue
Block a user