From dff4b915253efb282b7659aea60f6f6942ac4d74 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sat, 22 Aug 2020 20:07:48 +0200 Subject: [PATCH] add documentation --- .drone.jsonnet | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- .drone.yml | 43 +++++++++++++++++++++++++++++++++++++++++-- _index.md | 9 +++++++++ prefix.md | 26 ++++++++++++++++++++++++++ wrap.md | 26 ++++++++++++++++++++++++++ 5 files changed, 151 insertions(+), 3 deletions(-) create mode 100644 _index.md create mode 100644 prefix.md create mode 100644 wrap.md diff --git a/.drone.jsonnet b/.drone.jsonnet index 8ddd5de..63ceb37 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -107,6 +107,53 @@ local PipelineBuild = { }, }; +local PipelineDocumentation = { + kind: 'pipeline', + name: 'documentation', + platform: { + os: 'linux', + arch: 'amd64', + }, + steps: [ + { + name: 'publish', + image: 'plugins/gh-pages', + settings: { + netrc_machine: 'gitea.rknet.org', + pages_directory: 'docs/', + password: { + from_secret: 'gitea_token', + }, + remote_url: 'https://gitea.rknet.org/ansible/${DRONE_REPO_NAME}', + target_branch: 'docs', + username: { + from_secret: 'gitea_username', + }, + }, + }, + { + name: 'trigger', + image: 'plugins/downstream', + settings: { + fork: true, + repositories: [ + 'ansible/ansible-galaxy', + ], + server: 'https://drone.rknet.org', + token: { + from_secret: 'drone_token', + }, + }, + }, + ], + depends_on: [ + 'build', + ], + trigger: { + ref: ['refs/heads/master', 'refs/tags/**'], + }, +}; + local PipelineNotifications = { kind: 'pipeline', name: 'notifications', @@ -128,7 +175,7 @@ local PipelineNotifications = { }, ], depends_on: [ - 'build', + 'documentation', ], trigger: { ref: ['refs/heads/master', 'refs/tags/**'], @@ -140,5 +187,6 @@ local PipelineNotifications = { PipelineLint, PipelineTest, PipelineBuild, + PipelineDocumentation, PipelineNotifications, ] diff --git a/.drone.yml b/.drone.yml index d7bee63..e1ef57b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -128,6 +128,45 @@ trigger: depends_on: - test +--- +kind: pipeline +name: documentation + +platform: + os: linux + arch: amd64 + +steps: +- name: publish + image: plugins/gh-pages + settings: + netrc_machine: gitea.rknet.org + pages_directory: docs/ + password: + from_secret: gitea_token + remote_url: https://gitea.rknet.org/ansible/${DRONE_REPO_NAME} + target_branch: docs + username: + from_secret: gitea_username + +- name: trigger + image: plugins/downstream + settings: + fork: true + repositories: + - ansible/ansible-galaxy + server: https://drone.rknet.org + token: + from_secret: drone_token + +trigger: + ref: + - refs/heads/master + - refs/tags/** + +depends_on: +- build + --- kind: pipeline name: notifications @@ -159,10 +198,10 @@ trigger: - failure depends_on: -- build +- documentation --- kind: signature -hmac: a9bdb4a4a7aaab0c2a68a9c5f48ad4fcd0172a41f299ab7efff9917522ccae77 +hmac: 6577f5addbd95475811bbdc61f8d02528ad73703e4b7c598afd4a7e8e827327f ... diff --git a/_index.md b/_index.md new file mode 100644 index 0000000..9474465 --- /dev/null +++ b/_index.md @@ -0,0 +1,9 @@ +--- +title: Filters +geekdocFlatSection: true +--- + +Collection of some useful custom Jinja2 filters for Ansible. + +{{< toc-tree >}} + diff --git a/prefix.md b/prefix.md new file mode 100644 index 0000000..0887c1b --- /dev/null +++ b/prefix.md @@ -0,0 +1,26 @@ +Simple filter to prefix all items from a list. Default prefix will be `--` but you can also pass a custom one. + +## Example + +```Yaml +my_list: + - item1 + - item2 + +{{ my_list | prefix | join(' ') }} + +# result: +# "--item1 --item2" +``` + +Or pass a custom prefix: +```Yaml +my_list: + - item1 + - item2 + +{{ my_list | prefix(prefix='-') | join(' ') }} + +# result: +# "-item1 -item2" +``` diff --git a/wrap.md b/wrap.md new file mode 100644 index 0000000..1a1032e --- /dev/null +++ b/wrap.md @@ -0,0 +1,26 @@ +Simple filter to wrap all items form a list. Default will wrap items in single quotes but you can also pass a custom wrapper character. + +## Example + +```Yaml +my_list: + - item1 + - item2 + +{{ my_list | wrap | join(',') }} + +# result: +# "'item1','item2'" +``` + +Or pass a custom wrapper: +```Yaml +my_list: + - item1 + - item2 + +{{ my_list | wrap(wrapper='/') | join(',') }} + +# result: +# "/item1/,/item2/" +```