Skip to content
This repository was archived by the owner on May 31, 2023. It is now read-only.

Commit 9009d24

Browse files
author
Jesse Pretorius
authored
Merge pull request #57 from cloudalchemy/molecule2
upgrade to molecule 2.x
2 parents 8fccf7b + 7a207c0 commit 9009d24

26 files changed

+426
-214
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ env:
88
- ANSIBLE='ansible>=2.4.0,<2.5.0'
99
- ANSIBLE='ansible>=2.5.0,<2.6.0'
1010
install:
11-
- pip install ${ANSIBLE} 'ansible-lint>=3.4.15' 'molecule==1.25.0' docker git-semver 'testinfra>=1.7.0,<=1.10.1'
11+
- pip install ${ANSIBLE} 'ansible-lint>=3.4.15' 'molecule>=2.13.0' docker git-semver 'testinfra>=1.7.0'
1212
script:
13-
- molecule test
13+
- molecule test --all
1414
deploy:
1515
provider: script
1616
skip_cleanup: true

.travis/images.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

.yamllint

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
extends: default
2+
ignore: |
3+
.travis/
4+
.travis.yml
5+
meta/
6+
7+
rules:
8+
braces:
9+
max-spaces-inside: 1
10+
level: error
11+
brackets:
12+
max-spaces-inside: 1
13+
level: error
14+
line-length: disable

CONTRIBUTING.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ This document provides an overview of how you can participate in improving this
44

55
## Communication
66

7+
### IRC
8+
9+
You can talk with us on #cloudalchemy channel on freenode.
10+
711
### GitHub repositories
812

9-
Much of the issues, goals and ideas are tracked in the respective projects in GitHub. Please use this channel to report bugs and post ideas.
13+
Much of the issues, goals and ideas are tracked in the respective projects in GitHub. Please use this channel to report bugs.
1014

1115
## git and GitHub
1216

@@ -28,7 +32,15 @@ Some great guidelines can be found [here](https://wiki.openstack.org/wiki/GitCom
2832

2933
## Releases
3034

31-
Generally we try to stick to semantic versioning, where every accepted PR is treated as patch or minor feature and version is released accordingly by our CI pipeline.
35+
We try to stick to semantic versioning and our releases are made by CI pipeline. It is done by assigning a keyword (in a way similar to travis [`[ci skip]`](https://docs.travis-ci.com/user/customizing-the-build#Skipping-a-build)) to a commit with merge request. Available keywords are (square brackets are important!):
36+
37+
* `[patch]`, `[fix]` - for PATCH version release
38+
* `[minor]`, `[feature]`, `[feat]` - for MINOR version release
39+
* `[major]`, `[breaking change]` - for MAJOR version release
40+
41+
## Changelog
42+
43+
Changelog is generateg automatically on every merged Pull Request and all information is taken from github issues, PRs and labels.
3244

3345
## Expectations
3446

@@ -45,13 +57,16 @@ We try to provide production ready ansible roles which should be as much zero-co
4557

4658
### Add tests
4759

48-
We try to have as much tests written in testinfra framework as possible, so when you copy file, some template or starting some server just add couple of lines in [/tests/test)default.py](test_default.py) file. If you want to know how to write tests in testinfra, go to their [docs](http://testinfra.readthedocs.io/en/latest/index.html).
60+
Currently we are using two test scenarios located in [/molecule](molecule) directory. First ([default](molecule/default/molecule.yml)) one is testing default configuration without any additional variables, second one ([alternative](molecule/alternative/molecule.yml)) is testing what happens when many variables from [/defaults/main.yml](defaults/main.yml) are changed. When adding new functionalities please add tests to proper scenarios. Tests are written in testinfra framework and are located in `/tests` subdirectory of scenario directory (for example default tests are in [/molecule/default/tests](molecule/default/tests)).
61+
More information about:
62+
- [testinfra](http://testinfra.readthedocs.io/en/latest/index.html)
63+
- [molecule](https://molecule.readthedocs.io/en/latest/index.html)
4964

5065
### Follow best practices
5166

5267
Please follow [ansible best practices](http://docs.ansible.com/ansible/latest/playbooks_best_practices.html) and especially provide meaningful names to tasks and even comments where needed.
5368

54-
Our test framework automatically lints code with [`ansible-lint`](https://github.com/willthames/ansible-lint) command so be sure to follow it's rules.
69+
Our test framework automatically lints code with [`yamllint`](https://yamllint.readthedocs.io) and [`ansible-lint`](https://github.com/willthames/ansible-lint) programs so be sure to follow their rules.
5570

5671
Remember: Code is generally read much more often than written.
5772

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2017-2018 Pawel Krupa and Roman Demachkovych
3+
Copyright (c) 2017-2018 Pawel Krupa, Roman Demachkovych
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,21 @@ We provide demo site for full monitoring solution based on prometheus and grafan
7272
7373
## Local Testing
7474
75-
The preferred way of locally testing the role is to use Docker and [molecule](https://github.com/metacloud/molecule) (v1.25). You will have to install Docker on your system. See Get started for a Docker package suitable to for your system.
75+
The preferred way of locally testing the role is to use Docker and [molecule](https://github.com/metacloud/molecule) (v2.x). You will have to install Docker on your system. See Get started for a Docker package suitable to for your system.
7676
All packages you need to can be specified in one line:
7777
```sh
78-
pip install ansible 'ansible-lint>=3.4.15' 'molecule==1.25.0' docker 'testinfra>=1.7.0,<=1.10.1'
78+
pip install ansible 'ansible-lint>=3.4.15' 'molecule>2.13.0' docker 'testinfra>=1.7.0' jmespath
7979
```
80-
This should be similiar to one listed in `.travis.yml` file in `install` section.
80+
This should be similar to one listed in `.travis.yml` file in `install` section.
8181
After installing test suit you can run test by running
8282
```sh
83-
molecule test
83+
molecule test --all
8484
```
85-
For more information about molecule go to their [docs](http://molecule.readthedocs.io/en/stable-1.25/).
85+
For more information about molecule go to their [docs](http://molecule.readthedocs.io/en/latest/).
86+
87+
## Travis CI
88+
89+
Combining molecule and travis CI allows us to test how new PRs will behave when used with multiple ansible versions and multiple operating systems. This also allows use to create test scenarios for different role configurations. As a result we have a quite large test matrix (42 parallel role executions in case of [ansible-prometheus](https://github.com/cloudalchemy/ansible-prometheus)) which will take more time than local testing, so please be patient.
8690

8791
## Contributing
8892

defaults/main.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ grafana_server:
2121
socket: ""
2222
cert_key: ""
2323
cert_file: ""
24-
enable_gzip: False
24+
enable_gzip: false
2525
static_root_path: public
2626
router_logging: false
2727

@@ -34,7 +34,7 @@ grafana_security:
3434
# login_remember_days: 7
3535
# cookie_username: grafana_user
3636
# cookie_remember_name: grafana_remember
37-
# disable_gravatar: True
37+
# disable_gravatar: true
3838
# data_source_proxy_whitelist:
3939

4040
# Database setup
@@ -52,17 +52,17 @@ grafana_database:
5252
# log_queries: ""
5353

5454
# User management and registration
55-
grafana_welcome_email_on_sign_up: False
55+
grafana_welcome_email_on_sign_up: false
5656
grafana_users:
57-
allow_sign_up: False
58-
# allow_org_create: True
59-
# auto_assign_org: True
57+
allow_sign_up: false
58+
# allow_org_create: true
59+
# auto_assign_org: true
6060
auto_assign_org_role: Viewer
61-
# login_hint: "email or username"
61+
# login_hint: "email or username"
6262
default_theme: dark
63-
# external_manage_link_url: ""
64-
# external_manage_link_name: ""
65-
# external_manage_info: ""
63+
# external_manage_link_url: ""
64+
# external_manage_link_name: ""
65+
# external_manage_info: ""
6666

6767
# grafana authentication mechanisms
6868
grafana_auth: {}
@@ -74,14 +74,14 @@ grafana_auth: {}
7474
# ldap:
7575
# config_file: "/etc/grafana/ldap.toml"
7676
# allow_sign_up: False
77-
# basic: True
77+
# basic: true
7878

7979
grafana_session: {}
8080
# provider: file
8181
# provider_config: "sessions"
8282

8383
grafana_analytics: {}
84-
# reporting_enabled: True
84+
# reporting_enabled: true
8585
# google_analytics_ua_id: ""
8686

8787
# Set this for mail notifications
@@ -92,7 +92,7 @@ grafana_smtp: {}
9292
# from_address:
9393

9494
# Enable grafana alerting mechanism
95-
grafana_alerting: True
95+
grafana_alerting: true
9696

9797
# Internal grafana metrics system
9898
grafana_metrics: {}
@@ -109,10 +109,10 @@ grafana_tracing: {}
109109
# sampler_param: 1
110110

111111
grafana_snapshots: {}
112-
# external_enabled: True
112+
# external_enabled: true
113113
# external_snapshot_url: "https://snapshots-origin.raintank.io"
114114
# external_snapshot_name: "Publish to snapshot.raintank.io"
115-
# snapshot_remove_expired: True
115+
# snapshot_remove_expired: true
116116
# snapshot_TTL_days: 90
117117

118118
# External image store

molecule.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.

molecule/alternative/molecule.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
dependency:
3+
name: galaxy
4+
driver:
5+
name: docker
6+
lint:
7+
name: yamllint
8+
platforms:
9+
- name: bionic
10+
image: paulfantom/ubuntu-molecule:18.04
11+
privileged: true
12+
volumes:
13+
- /sys/fs/cgroup:/sys/fs/cgroup:ro
14+
- name: xenial
15+
image: paulfantom/ubuntu-molecule:16.04
16+
privileged: true
17+
volumes:
18+
- /sys/fs/cgroup:/sys/fs/cgroup:ro
19+
- name: stretch
20+
image: paulfantom/debian-molecule:9
21+
privileged: true
22+
volumes:
23+
- /sys/fs/cgroup:/sys/fs/cgroup:ro
24+
- name: jessie
25+
image: paulfantom/debian-molecule:8
26+
privileged: true
27+
volumes:
28+
- /sys/fs/cgroup:/sys/fs/cgroup:ro
29+
- name: centos7
30+
image: paulfantom/centos-molecule:7
31+
privileged: true
32+
volumes:
33+
- /sys/fs/cgroup:/sys/fs/cgroup:ro
34+
- name: fedora
35+
image: paulfantom/fedora-molecule:27
36+
privileged: true
37+
volumes:
38+
- /sys/fs/cgroup:/sys/fs/cgroup:ro
39+
provisioner:
40+
name: ansible
41+
lint:
42+
name: ansible-lint
43+
playbooks:
44+
create: ../default/create.yml
45+
prepare: ../default/prepare.yml
46+
converge: playbook.yml
47+
destroy: ../default/destroy.yml
48+
scenario:
49+
name: alternative
50+
verifier:
51+
name: testinfra
52+
lint:
53+
name: flake8
54+
enabled: true

molecule/alternative/playbook.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
- hosts: all
3+
any_errors_fatal: true
4+
roles:
5+
- ansible-grafana
6+
vars:
7+
grafana_version: 5.1.0
8+
grafana_security:
9+
admin_user: admin
10+
admin_password: "password"
11+
grafana_address: "127.0.0.1"
12+
grafana_auth:
13+
disable_login_form: false
14+
disable_signout_menu: false
15+
anonymous:
16+
org_name: "Main Organization"
17+
org_role: Viewer
18+
basic: true
19+
grafana_api_keys:
20+
- name: "admin"
21+
role: "Admin"
22+
- name: "viewer"
23+
role: "Viewer"
24+
- name: "editor"
25+
role: "Editor"
26+
grafana_api_keys_dir: "/tmp/grafana/keys"
27+
grafana_plugins:
28+
- raintank-worldping-app
29+
grafana_dashboards:
30+
- dashboard_id: '1860'
31+
revision_id: '4'
32+
datasource: 'Prometheus'
33+
- dashboard_id: '358'
34+
revision_id: '1'
35+
datasource: 'Prometheus'
36+
grafana_datasources:
37+
- name: "Prometheus"
38+
type: "prometheus"
39+
access: "proxy"
40+
url: "http://prometheus.mydomain"
41+
basicAuth: true
42+
basicAuthUser: "admin"
43+
basicAuthPassword: "password"
44+
isDefault: true
45+
jsonData: '{"tlsAuth":false,"tlsAuthWithCACert":false,"tlsSkipVerify":true}'

0 commit comments

Comments
 (0)