Yaml and Ansible linting in Molecule (#141)

* Removed old ansible-lint outside of molecule

* Yamlint

* Enabled ansible-lint with minimal rules

* Removed ansible-lint job
This commit is contained in:
Przemyslaw Rzad 2019-07-11 10:17:02 +02:00 committed by GitHub
parent 3f27b98b8b
commit 1da1acbfbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 61 additions and 42 deletions

@ -55,12 +55,6 @@ jobs:
- restore_cache:
key: initialize-{{ .Environment.CIRCLE_SHA1 }}
- run: yarn run lint
ansible-lint:
docker:
- image: particlekit/ansible-lint
steps:
- checkout
- run: ./deployment/lint.sh
test:
docker:
- image: circleci/node:10.15
@ -151,7 +145,6 @@ workflows:
filters:
branches:
only: master
- ansible-lint
- oracle-e2e
- ui-e2e
- monitor-e2e

@ -76,14 +76,6 @@ Running linter for all JS projects:
yarn lint
```
Running linter for all Ansible playbooks:
- [ansible-lint](https://github.com/ansible/ansible-lint) is required
```
yarn ansible-lint
```
## Tests
Running tests for all projects:

@ -1,3 +1,4 @@
---
## General settings
BRIDGE_MODE: "ERC_TO_NATIVE"
HOME_NATIVE_NAME: "xDai"
@ -14,7 +15,7 @@ FOREIGN_RPC_URL: "https://mainnet.infura.io"
FOREIGN_NAME: "Ethereum Mainnet"
FOREIGN_WITHOUT_EVENTS: false
FOREIGN_BRIDGE_ADDRESS: "0x4aa42145Aa6Ebf72e164C9bBC74fbD3788045016"
ERC20_TOKEN_ADDRESS: "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"
ERC20_TOKEN_ADDRESS: "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"
FOREIGN_POLLING_INTERVAL: 5000
## Home Gasprice

@ -1,3 +1,4 @@
---
## General settings
BRIDGE_MODE: "NATIVE_TO_ERC"
HOME_NATIVE_NAME: "POA"

@ -1,3 +1,4 @@
---
## General settings
BRIDGE_MODE: "NATIVE_TO_ERC"
HOME_NATIVE_NAME: "ETC"

@ -1,10 +1,11 @@
---
sokol-kovan:
children:
oracle:
hosts:
127.0.0.1:
ansible_user: ubuntu
VALIDATOR_ADDRESS_PRIVATE_KEY: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
VALIDATOR_ADDRESS_PRIVATE_KEY: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
#syslog_server_port: "udp://127.0.0.1:514"
ui:
hosts:

@ -1,3 +0,0 @@
#!/bin/bash
cd $(dirname $0)
ansible-lint -v -t bug ./oracle/roles/**

@ -1,4 +1,5 @@
FROM python:3.7-stretch
RUN curl -fsSL https://get.docker.com | sh
RUN pip3 install docker molecule==2.22rc1 molecule[docker] flake8
WORKDIR runner
COPY . .

@ -5,7 +5,10 @@ driver:
name: docker
lint:
name: yamllint
enabled: False
enabled: True
options:
config-data:
ignore: ../../hosts.yml
platforms:
- name: oracle-host
groups:
@ -21,14 +24,16 @@ provisioner:
name: ansible
lint:
name: ansible-lint
enabled: False
enabled: True
options:
r: ["bug"]
playbooks:
prepare: prepare.yml
converge: ../../site.yml
inventory:
host_vars:
oracle-host:
VALIDATOR_ADDRESS_PRIVATE_KEY: "8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9"
VALIDATOR_ADDRESS_PRIVATE_KEY: "8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9"
syslog_server_port: "udp://127.0.0.1:514"
bridge_repo_branch: $CODEBASE_BRANCH
verifier:

@ -7,7 +7,7 @@
name: "{{ packages }}"
vars:
packages:
- apt-transport-https
- rsyslog
- apt-transport-https
- rsyslog
- shell: service rsyslog start
- shell: groupadd docker && chgrp docker /var/run/docker.sock

@ -1,3 +1,4 @@
---
version: '3.0'
services:
molecule_runner:

@ -1,3 +1,4 @@
---
docker_compose_version: 1.23.2
compose_service_user: poadocker
bridge_path: "/home/{{ compose_service_user }}/bridge"

@ -1,3 +1,4 @@
---
- name: restart rsyslog
service:
name: rsyslog

@ -1,8 +1,9 @@
---
- name: Install the gpg key for docker
apt_key:
url: "https://download.docker.com/linux/ubuntu/gpg"
state: present
- name: Install the docker repos
apt_repository:
repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
@ -30,7 +31,7 @@
owner: "root"
group: "root"
mode: "0755"
- name: Install python docker library
shell: pip3 install docker docker-compose setuptools
@ -49,7 +50,7 @@
- name: Configure auditd
blockinfile:
path: /etc/audit/audit.rules
block: |
block: |
-w /usr/bin/docker -p wa
-w /var/lib/docker -p wa
-w /etc/docker -p wa
@ -58,7 +59,7 @@
-w /etc/default/docker -p wa
-w /etc/docker/daemon.json -p wa
-w /usr/bin/docker-containerd -p wa
-w /usr/bin/docker-runc -p wa
-w /usr/bin/docker-runc -p wa
notify: restart auditd
- name: Configure docker engine

@ -1,3 +1,4 @@
---
- name: Set the local docker logs configuration file
template:
src: 30-docker.conf.j2

@ -1,3 +1,4 @@
---
- include_tasks: dependencies.yml
- include_tasks: repo.yml
- include_tasks: logging.yml

@ -1,3 +1,4 @@
---
- name: Get bridge repo
git:
repo: "{{ bridge_repo }}"

@ -1,2 +1,3 @@
---
dependencies:
- role: common

@ -1,3 +1,4 @@
---
- name: Launch container
shell: docker-compose up -d
args:

@ -1,3 +1,4 @@
---
- include_tasks: pre_config.yml
- include_tasks: jumpbox.yml
- include_tasks: servinstall.yml

@ -1,3 +1,4 @@
---
- name: Install .env config
template:
src: .env.j2

@ -8,7 +8,7 @@
dest: "/etc/init.d/tokenbridge-monitor"
owner: root
mode: 755
- name: "Start/Enable the service"
service:
name: "tokenbridge-monitor"

@ -1,3 +1,4 @@
---
bridge_path: "/home/{{ compose_service_user }}/bridge"
ALLOW_HTTP: no
QUEUE_URL: amqp://rabbit

@ -1,2 +1,3 @@
---
dependencies:
- role: common

@ -1,3 +1,4 @@
---
- name: Launch container
shell: docker-compose up -d
args:

@ -1,17 +1,18 @@
---
- name: Slurp docker compose file
slurp:
src: "{{ bridge_path }}/oracle/docker-compose.yml"
register: docker_compose_slurp
- name: Parse docker compose file
set_fact:
set_fact:
docker_compose_parsed: "{{ docker_compose_slurp['content'] | b64decode | from_yaml }}"
- name: Set logger to remote server
set_fact:
docker_compose_parsed: "{{ docker_compose_parsed |combine({'services': {item: {'logging': {'driver': 'syslog','options': {'tag': '{{.Name}}/{{.ID}}'}}}}}, recursive=True) }}"
with_items: "{{ docker_compose_parsed.services }}"
- name: Write new docker-compose file
copy:
content: "{{ docker_compose_parsed | to_yaml }}"

@ -1,3 +1,4 @@
---
- include_tasks: pre_config.yml
- include_tasks: logging.yml
- include_tasks: jumpbox.yml

@ -1,5 +1,6 @@
---
- name: Get blocks
become_user: "{{ compose_service_user }}"
become_user: "{{ compose_service_user }}"
shell: docker-compose run --entrypoint "node scripts/getValidatorStartBlocks.js" bridge_affirmation
args:
chdir: "{{ bridge_path }}/oracle"
@ -14,7 +15,7 @@
FOREIGN_START_BLOCK={{ (BLOCKS.stdout | from_json).foreignStartBlock }}
- name: Get validator address
become_user: "{{ compose_service_user }}"
become_user: "{{ compose_service_user }}"
shell: docker-compose run -e VALIDATOR_ADDRESS_PRIVATE_KEY="{{ VALIDATOR_ADDRESS_PRIVATE_KEY }}" --entrypoint "node scripts/privateKeyToAddress.js" bridge_affirmation
args:
chdir: "{{ bridge_path }}/oracle"

@ -1,3 +1,4 @@
---
- name: Install .env config
template:
src: .env.j2

@ -8,7 +8,7 @@
dest: "/etc/init.d/poabridge"
owner: root
mode: 755
- name: "Start/Enable poabridge service"
service:
name: "poabridge"

@ -1,2 +1,3 @@
---
dependencies:
- role: common

@ -1,3 +1,4 @@
---
- name: Launch container
shell: docker-compose up -d
args:

@ -1,17 +1,18 @@
---
- name: Slurp docker compose file
slurp:
src: "{{ bridge_path }}/ui/docker-compose.yml"
register: docker_compose_slurp
- name: Parse docker compose file
set_fact:
set_fact:
docker_compose_parsed: "{{ docker_compose_slurp['content'] | b64decode | from_yaml }}"
- name: Set logger to remote server
set_fact:
docker_compose_parsed: "{{ docker_compose_parsed |combine({'services': {item: {'logging': {'driver': 'syslog','options': {'tag': '{{.Name}}/{{.ID}}'}}}}}, recursive=True) }}"
with_items: "{{ docker_compose_parsed.services }}"
- name: Write new docker-compose file
copy:
content: "{{ docker_compose_parsed | to_yaml }}"

@ -1,3 +1,4 @@
---
- include_tasks: pre_config.yml
- include_tasks: logging.yml
- include_tasks: jumpbox.yml

@ -1,3 +1,4 @@
---
- name: Install .env config
template:
src: .env.j2

@ -8,7 +8,7 @@
dest: "/etc/init.d/tokenbridge-ui"
owner: root
mode: 755
- name: "Start/Enable the service"
service:
name: "tokenbridge-ui"

@ -1,15 +1,16 @@
---
- name: Install Oracle
hosts: oracle
become: true
roles:
roles:
- { role: oracle }
- name: Install UI
hosts: ui
become: true
roles:
roles:
- { role: ui }
- name: Install Monitor
hosts: monitor
become: true
roles:
roles:
- { role: monitor }

@ -1,3 +1,4 @@
---
version: '3'
services:
parity1:

@ -1,3 +1,4 @@
---
version: '2.4'
services:
monitor:

@ -1,3 +1,4 @@
---
version: '2.4'
services:
rabbit:

@ -35,7 +35,6 @@
"build": "yarn workspace ui run build",
"lint": "yarn wsrun --exclude poa-parity-bridge-contracts lint",
"test": "yarn wsrun --exclude monitor --exclude oracle-e2e --exclude ui-e2e test",
"ansible-lint": "./deployment/lint.sh",
"oracle-e2e": "./oracle-e2e/run-tests.sh",
"ui-e2e": "./ui-e2e/run-tests.sh",
"clean": "rm -rf ./node_modules ./**/node_modules ./**/**/node_modules ./**/build",

@ -1,3 +1,4 @@
---
version: '2.4'
services:
ui: