Skip to content

Commit

Permalink
doc: update README with meta/main.yml usage example
Browse files Browse the repository at this point in the history
  • Loading branch information
atosatto committed Mar 11, 2020
1 parent 4a241af commit a1e9740
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Given the following `requirements.yml` file in your current working directory

```bash
$ cat requirements.yml
---

# Prometheus
- name: atosatto.prometheus
Expand All @@ -45,11 +46,35 @@ $ cat requirements.yml
`ansible-requirements-lint` can be used to detect updates to the list of requirements with

```bash
$ bin/ansible-requirements-lint requirements.yml
$ ansible-requirements-lint requirements.yml
WARN: atosatto.prometheus: role not at the latest version, upgrade from v1.0.1 to v1.1.0.
WARN: atosatto.grafana: role not at the latest version, upgrade from v1.0.0 to v1.1.0.
```


In addition to requirements files, `ansible-requirements-lint` can also parse role dependencies
declared in the `meta/main.yml` file in your role directory

```bash
$ cat meta/main.yml
---

dependencies:
- role: atosatto.prometheus
version: v1.0.0
prometheus_release_tag: "v2.16.0"

- name: atosatto.alertmanager
version: v1.0.0
```

Running `ansible-requirements-lint` will produce the following results

```bash
$ ansible-requirements-lint meta/main.yml
WARN: atosatto.prometheus: role not at the latest version, upgrade from v1.0.0 to v1.1.0.
```

## License

MIT
Expand Down
3 changes: 2 additions & 1 deletion requirements/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ func parseRolesFromNodesList(nodes []*yaml.Node) ([]*Role, error) {
case k.Kind == yaml.ScalarNode && k.Value == "include":
role.Include = v.Value
case k.Kind == yaml.ScalarNode:
return nil, NewUnexpectedMappingNodeValueError(k.Line, k.Value)
// when parsing dependencies in the meta/main.yml format
// we might encounter some variables names, let's ignore them
default:
return nil, NewUnexpectedNodeKindError(k.Line, k.Kind)
}
Expand Down
1 change: 1 addition & 0 deletions requirements/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func TestParseMetaRequirementsFile(t *testing.T) {
- role: test.ansible-requirements-lint-role
version: v1.0.0
ansible_requirements_lint_role_variable: "ansible_requirements_lint"
- name: test.ansible-requirements-lint-name
version: v1.0.0
Expand Down

0 comments on commit a1e9740

Please sign in to comment.