From 818129c9acf6194cdac092bd2fcb0d83e88d1c24 Mon Sep 17 00:00:00 2001 From: L3D Date: Wed, 8 Jul 2020 14:01:03 +0200 Subject: [PATCH] initialize ansible role --- .github/FUNDING.yml | 4 + .github/license.svg | 217 +++++++++++++++++++++++++++++++++++++++++ LICENSE | 3 +- defaults/main.yml | 6 ++ tasks/main.yml | 8 ++ tasks/versioncheck.yml | 44 +++++++++ vars/main.yml | 7 ++ 7 files changed, 288 insertions(+), 1 deletion(-) create mode 100644 .github/FUNDING.yml create mode 100644 .github/license.svg create mode 100644 defaults/main.yml create mode 100644 tasks/main.yml create mode 100644 tasks/versioncheck.yml create mode 100644 vars/main.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..1fac358 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,4 @@ +# Feel free to add yourself after && during participating at this repo! + +github: [do1jlr] +liberapay: L3D diff --git a/.github/license.svg b/.github/license.svg new file mode 100644 index 0000000..4ab6d9a --- /dev/null +++ b/.github/license.svg @@ -0,0 +1,217 @@ + + + + + + image/svg+xml + + + + + + 3D <l3d@c3woc.de> + + + + + MIT License + + + + + + + + + + + + + + + + + + + + + + + + + + + MIT + MIT + + + license + license + + diff --git a/LICENSE b/LICENSE index 3bdf835..86c4832 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,7 @@ MIT License -Copyright (c) 2020 L3D +Copyright (c) 2020 L3D +Copyright (c) 2020 L3D and contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..e8221d2 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,6 @@ +--- +# should we do a version check? (recomended) +submodules_versioncheck: false + +postgresql_backup: + foo: bar diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..2b5a507 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,8 @@ +--- +- name: combine postgresql_backup configuration + set_fact: + ranger: "{{ _postgresql_backup|combine(postgresql_backup, recursive=True) }}" + +- include_tasks: versioncheck.yml + when: submodules_versioncheck|bool + diff --git a/tasks/versioncheck.yml b/tasks/versioncheck.yml new file mode 100644 index 0000000..9895582 --- /dev/null +++ b/tasks/versioncheck.yml @@ -0,0 +1,44 @@ +--- +- name: Create directory for versionscheck + become: true + file: + path: '/etc/.ansible-version' + state: directory + mode: 0755 + when: submodules_versioncheck|bool + +- name: check playbook version + become: true + slurp: + src: "/etc/.ansible-version/{{ playbook_version_path }}" + register: playbook_version + when: submodules_versioncheck|bool + ignore_errors: yes + +- name: Print remote role version + debug: + msg: "Remote role version: {{ playbook_version.content | default('Y3VycmVudGx5IG5vdCBkZXBsb3llZAo=') | b64decode | string }}" + when: submodules_versioncheck|bool + +- name: Print locale role version + debug: + msg: "Local role version: '{{ playbook_version_number|string }}'." + when: submodules_versioncheck|bool + +- name: Check if your version is outdated + fail: + msg: "Your ansible module has the version '{{ playbook_version_number }}' and is outdated. You need to update it!" + when: + - playbook_version.content|default("Mgo=")|b64decode|int - 1 >= playbook_version_number|int and submodules_versioncheck|bool + +- name: check if '/etc/ansible-version/' is empty + find: + paths: '/etc/ansible-version/' + register: filesFound + +- name: write new version to remote disk + become: true + copy: + content: "{{ playbook_version_number }}" + dest: "/etc/.ansible-version/{{ playbook_version_path }}" + when: submodules_versioncheck|bool diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..a9e1aea --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,7 @@ +--- +# versionscheck +playbook_version_number: 10 # should be int +playbook_version_path: 'role-postgresql-backup_roles-ansible_github.com.version' # unique string + +_postgresql_backup: + foo: bar