From 54caea0e8057369d76e9503dddee472f6601d387 Mon Sep 17 00:00:00 2001 From: L3D Date: Thu, 27 May 2021 16:18:04 +0200 Subject: [PATCH] change config --- README.md | 98 +++++++++++-------------------- defaults/main.yml | 34 +++++------ tasks/configure_custom_config.yml | 34 +++++------ tasks/configure_plugins.yml | 18 +++--- tasks/install-debian.yml | 2 +- tasks/main.yml | 18 +++--- tasks/setup_autostart.yml | 2 +- templates/weechat.service | 2 +- vars/main.yml | 16 +---- 9 files changed, 87 insertions(+), 137 deletions(-) diff --git a/README.md b/README.md index ec99768..d2a12b2 100644 --- a/README.md +++ b/README.md @@ -17,82 +17,74 @@ Ansible role to install and configure weechat. ---------- ```yaml - weechat: - install: true + weechat__install: true ``` -+ ``weechat.install: true``: This role should install weechat. On debian based OS we add the official weechat apt source and install some plugin support and weechat-doc. -+ ``weechat.install: false``: We do not install weechat ++ ``weechat__install: true``: This role should install weechat. On debian based OS we add the official weechat apt source and install some plugin support and weechat-doc. ++ ``weechat__install: false``: We do not install weechat ```yaml -weechat: - autostart: false +weechat__autostart: false ``` -+ ``weechat.autostart: false``: We do not install any autostart mechanism -+ ``weechat.autostart: true``: This role install tmux and creates a systemd service to launch weechat inside a tmux session as user ``{{ weechat.user }}`` ++ ``weechat__autostart: false``: We do not install any autostart mechanism ++ ``weechat__autostart: true``: This role install tmux and creates a systemd service to launch weechat inside a tmux session as user ``{{ weechat__user }}`` ```yaml -weechat: - install_plugins: false +weechat__install_plugins: false ``` -+ ``weechat.install_plugins: false``: we do not install any weechat plugins -+ ``weechat.install_plugins: true``: We do install all official plugins specified in ``{{ weecat.plugins }}`` dict. ++ ``weechat__install_plugins: false``: we do not install any weechat plugins ++ ``weechat__install_plugins: true``: We do install all official plugins specified in ``{{ weecat.plugins }}`` dict. ```yaml -weechat: - use_custom_config: false +weechat__use_custom_config: false ``` -+ ``weechat.use_custom_config: false``: You do not provide a custom config from your own git repository -+ ``weechat.use_custom_config: true``: You have your weechat configuration in a own git repository and want to use it ++ ``weechat__use_custom_config: false``: You do not provide a custom config from your own git repository ++ ``weechat__use_custom_config: true``: You have your weechat configuration in a own git repository and want to use it ```yaml -weechat: - install_plugins: false +weechat__install_plugins: false ``` -+ ``weechat.install_plugins: false`` we do not install any official weechat plugins -+ ``weechat.install_plugins: true`` we install the official weechat plugins defined in the ``{{ weechat.plugins: [] }}`` directory. ++ ``weechat__install_plugins: false`` we do not install any official weechat plugins ++ ``weechat__install_plugins: true`` we install the official weechat plugins defined in the ``{{ weechat__plugins: [] }}`` directory. ```yaml -weechat: - plugins: - - go.py - - iset.pl +weechat__plugins: + - go.py + - iset.pl ``` -+ Example ``weechat.plugins: []`` list ++ Example ``weechat__plugins: []`` list ```yaml -weechat: - user: "{{ ansible_user_id }}" +weechat__user: "{{ ansible_user_id }}" ``` -+ the user to use weechat with. This value is used in the ``autostart`` task, the ``custom_config`` task and the ``{{ weechat.home_directory }}`` variable ++ the user to use weechat with. This value is used in the ``autostart`` task, the ``custom_config`` task and the ``{{ weechat__home_directory }}`` variable ```yaml -weechat: - home_directory: "{{ ansible_env.HOME | default('/home/{{ weechat.user }}') }}" +weechat__home_directory: "{{ ansible_env.HOME | default('/home/{{ weechat__user }}') }}" ``` -+ the path where the weechat home is located. If the variable ``{{ ansible_env.HOME }}`` is not set it will use ``"/home/{{ weechat.user }}"`` as fallback. ++ the path where the weechat home is located. If the variable ``{{ ansible_env.HOME }}`` is not set it will use ``"/home/{{ weechat__user }}"`` as fallback. ```yaml -weechat: - gpg_id: '11E9DE8848F2B65222AA75B8D1820DB22A11534E' +weechat__gpg_id: '11E9DE8848F2B65222AA75B8D1820DB22A11534E' ``` + This is the gpg fingerprint from the [official weechat debian repo](https://weechat.org/download/debian/) ```yaml -weechat: - custom_config: - private_repo: false +weechat__custom_private_repo: false ``` + The path to your git repo with your personal weechat config. -+ This role clones the repo to the ``"{{ weechat.home_directory }}/.weechat"`` directory. *(Also known al your local .weechat directory.)* It will fail if you already have files and/or folders in your local .weechat dorectory. ++ This role clones the repo to the ``"{{ weechat__home_directory }}/.weechat"`` directory. *(Also known al your local .weechat directory.)* It will fail if you already have files and/or folders in your local .weechat dorectory. + You have to add, commit and push the local changes in your local .weechat folder manually. Please be aware that it is a good idea to disable your log or at least add the weechatlog folder to your .gitignore file in your personal weechat config. ```yaml -weechat: - custom_config: - gen_ssh_key_pair: true +weechat__custom_gen_ssh_key_pair: true ``` -+ ``weechat.custom_config.gen_ssh_key_pair: true``: We will generate a eleptic curve ssh key *(if it not already exist at ``"{{ weechat.home_directory }}/.ssh/id_ed25519"``)* and print the public key to the prompt. This will give you the time to add this public key to your private git repo for your own weechat config as deploy key. This is required to download your private repo withour username/password. This requires that you set ``{{ weechat.custom_config.private_repo }}`` to the ssh accessable version of your git repo. -+ ``weechat.custom_config.gen_ssh_key_pair: false``: We do not manage access to the git repo with your weechat config. ++ ``weechat__custom_gen_ssh_key_pair: true``: We will generate a eleptic curve ssh key *(if it not already exist at ``"{{ weechat__home_directory }}/.ssh/id_ed25519"``)* and print the public key to the prompt. This will give you the time to add this public key to your private git repo for your own weechat config as deploy key. This is required to download your private repo withour username/password. This requires that you set ``{{ weechat__custom_private_repo }}`` to the ssh accessable version of your git repo. ++ ``weechat__custom_gen_ssh_key_pair: false``: We do not manage access to the git repo with your weechat config. + +```yaml +weechat__custom_version: main +``` ++ ``weechat__custom_version: main``: set the git branch, tag, hash or version this role should use if you use a custom git repo for your weechat config. ```txt WARNING @@ -127,26 +119,4 @@ If you missing a feature, found a bug or have questions about this role please f This role is tested with [these github-action](https://github.com/search?q=topic%3Acheck-ansible+topic%3Agithub-actions+org%3Aroles-ansible&type=Repositories) tests for different versions of differen linux systems. Linting is tested via travis-ci and the [ansible-lint action](https://github.com/marketplace/actions/ansible-lint). If you want to find out more about our tests, please have a look at the github marketplace. -| test status | Github Marketplace | -| :--------- | :---------------- | -| [![Travis Build Status](https://travis-ci.org/chaos-bodensee/role_weechat.svg?branch=master)](https://travis-ci.org/chaos-bodensee/role_weechat) | [.travis.yml](https://github.com/chaos-bodensee/role_weechat/blob/master/.travis.yml) | -||| -| [![Ansible Lint check](https://github.com/chaos-bodensee/role_weechat/workflows/Ansible%20Lint%20check/badge.svg)](https://github.com/chaos-bodensee/role_weechat/actions?query=workflow%3A%22Ansible+Lint+check%22) | [ansible-lint action](https://github.com/marketplace/actions/ansible-lint) -| [![Ansible check debian:stable](https://github.com/chaos-bodensee/role_weechat/workflows/Ansible%20check%20debian:stable/badge.svg)](https://github.com/chaos-bodensee/role_weechat/actions?query=workflow%3A%22Ansible+check+debian%3Astable%22) | [ansible test with debian stable](https://github.com/marketplace/actions/check-ansible-debian-stable) | -| [![Ansible check debian:latest](https://github.com/chaos-bodensee/role_weechat/workflows/Ansible%20check%20debian:latest/badge.svg)](https://github.com/chaos-bodensee/role_weechat/actions?query=workflow%3A%22Ansible+check+debian%3Alatest%22) | [ansible test with debian latest](https://github.com/marketplace/actions/check-ansible-debian-latest) | -| [![Ansible check debian:sid](https://github.com/chaos-bodensee/role_weechat/workflows/Ansible%20check%20debian:sid/badge.svg)](https://github.com/chaos-bodensee/role_weechat/actions?query=workflow%3A%22Ansible+check+debian%3Asid%22) | [ansible test with debian sid](https://github.com/marketplace/actions/check-ansible-debian-sid) | -| [![Ansible check debian:buster](https://github.com/chaos-bodensee/role_weechat/workflows/Ansible%20check%20debian:buster/badge.svg)](https://github.com/chaos-bodensee/role_weechat/actions?query=workflow%3A%22Ansible+check+debian%3Abuster%22) | [ansible test with debian buster](https://github.com/marketplace/actions/check-ansible-debian-buster) | -| [![Ansible check debian:stretch](https://github.com/chaos-bodensee/role_weechat/workflows/Ansible%20check%20debian:stretch/badge.svg)](https://github.com/chaos-bodensee/role_weechat/actions?query=workflow%3A%22Ansible+check+debian%3Astretch%22) | [ansible test with debian stretch](https://github.com/marketplace/actions/check-ansible-debian-stretch) | -| | | -| [![Ansible check archlinux:latest](https://github.com/chaos-bodensee/role_weechat/workflows/Ansible%20check%20archlinux:latest/badge.svg)](https://github.com/chaos-bodensee/role_weechat/actions?query=workflow%3A%22Ansible+check+archlinux%3Alatest%22) | [ansible test with archlinux latest](https://github.com/marketplace/actions/check-ansible-archlinux-latest) | -| | | -| [![Ansible check ubuntu:latest](https://github.com/chaos-bodensee/role_weechat/workflows/Ansible%20check%20ubuntu:latest/badge.svg)](https://github.com/chaos-bodensee/role_weechat/actions?query=workflow%3A%22Ansible+check+ubuntu%3Alatest%22) | [ansible test with ubuntu latest](https://github.com/marketplace/actions/check-ansible-ubuntu-latest) | -| [![Ansible check ubuntu:bionic](https://github.com/chaos-bodensee/role_weechat/workflows/Ansible%20check%20ubuntu:bionic/badge.svg)](https://github.com/chaos-bodensee/role_weechat/actions?query=workflow%3A%22Ansible+check+ubuntu%3Abionic%22) | [ansible test with ubuntu bionic](https://github.com/marketplace/actions/check-ansible-ubuntu-bionic) | -| [![Ansible check ubuntu:eoan](https://github.com/chaos-bodensee/role_weechat/workflows/Ansible%20check%20ubuntu:eoan/badge.svg)](https://github.com/chaos-bodensee/role_weechat/actions?query=workflow%3A%22Ansible+check+ubuntu%3Aeoan%22) | [ansible test with ubuntu eoan](https://github.com/marketplace/actions/check-ansible-ubuntu-eoan) | -| [![Ansible check ubuntu:trusty](https://github.com/chaos-bodensee/role_weechat/workflows/Ansible%20check%20ubuntu:trusty/badge.svg)](https://github.com/chaos-bodensee/role_weechat/actions?query=workflow%3A%22Ansible+check+ubuntu%3Atrusty%22) | [ansible test with ubuntu trusty](https://github.com/marketplace/actions/check-ansible-ubuntu-trusty) | -| | | -| [![Ansible check fedora:latest](https://github.com/chaos-bodensee/role_weechat/workflows/Ansible%20check%20fedora:latest/badge.svg)](https://github.com/chaos-bodensee/role_weechat/actions?query=workflow%3A%22Ansible+check+fedora%3Alatest%22) | [ansible test with fedora latest](https://github.com/marketplace/actions/check-ansible-fedora-latest) | -| [![Ansible check fedora:33](https://github.com/chaos-bodensee/role_weechat/workflows/Ansible%20check%20fedora:33/badge.svg)](https://github.com/chaos-bodensee/role_weechat/actions?query=workflow%3A%22Ansible+check+fedora%3A33%22) | [ansible test with fedora 33](https://github.com/marketplace/actions/check-ansible-fedora-33) | -| [![Ansible check fedora:32](https://github.com/chaos-bodensee/role_weechat/workflows/Ansible%20check%20fedora:32/badge.svg)](https://github.com/chaos-bodensee/role_weechat/actions?query=workflow%3A%22Ansible+check+fedora%3A32%22) | [ansible test with fedora 32](https://github.com/marketplace/actions/check-ansible-fedora-32) | -| [![Ansible check fedora:31](https://github.com/chaos-bodensee/role_weechat/workflows/Ansible%20check%20fedora:31/badge.svg)](https://github.com/chaos-bodensee/role_weechat/actions?query=workflow%3A%22Ansible+check+fedora%3A31%22) | [ansible test with fedora 31](https://github.com/marketplace/actions/check-ansible-fedora-31) | diff --git a/defaults/main.yml b/defaults/main.yml index 246772a..f602381 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,30 +1,28 @@ --- -weechat: # should we install weechat? - install: true +weechat__install: true # autostart weechat via systemd in a tmux session? - autostart: false +weechat__autostart: false # should we install official weechat plugins - install_plugins: false +weechat__install_plugins: false # custom weechat config (requires some manual interaction for long-term usage) - use_custom_config: false +weechat__use_custom_config: false # user to install and use weechat - user: "{{ ansible_user_id }}" +weechat__user: "{{ ansible_user_id }}" # where is our home direcotory for weechat - home_directory: "{{ ansible_env.HOME | default('/home/{{ weechat.user }}') }}" +weechat__home_directory: "{{ ansible_env.HOME | default('/home/{{ weechat__user }}') }}" # plugins we want - plugins: [] +weechat__plugins: [] # weechat gpg key for debian/ubuntu repo - gpg_id: '11E9DE8848F2B65222AA75B8D1820DB22A11534E' - # custom private config - custom_config: - # path to your custom weechat config (with plugins) git repo - # ( eg. git@github.com:/.git ) - private_repo: false - # generate ssh key pair (if not available) - gen_ssh_key_pair: true - # the tag, commit or branch we should check out - version: 'main' +weechat__gpg_id: '11E9DE8848F2B65222AA75B8D1820DB22A11534E' + +# path to your custom weechat config (with plugins) git repo +# ( eg. git@github.com:/.git ) +weechat__custom_private_repo: false +# generate ssh key pair (if not available) +weechat__custom_gen_ssh_key_pair: true +# the tag, commit or branch we should check out +weechat__custom_version: 'main' # version check for this role? (true is recomended) submodules_versioncheck: false diff --git a/tasks/configure_custom_config.yml b/tasks/configure_custom_config.yml index d5cfce3..a2ccaac 100644 --- a/tasks/configure_custom_config.yml +++ b/tasks/configure_custom_config.yml @@ -2,11 +2,11 @@ - name: create ssh key pair (if needed) become: true community.crypto.openssh_keypair: - path: "{{ weechat.home_directory }}/.ssh/id_ed25519" + path: "{{ weechat__home_directory }}/.ssh/id_ed25519" type: ed25519 - owner: "{{ weechat.user }}" + owner: "{{ weechat__user }}" register: ssh_key_pair - when: weechat.custom_config.gen_ssh_key_pair | bool + when: weechat__custom_gen_ssh_key_pair | bool - name: print ssh public key to user ansible.builtin.pause: @@ -29,7 +29,7 @@ push any local changes and you have to do this manually by yourself. when: - - weechat.custom_config.gen_ssh_key_pair | bool + - weechat__custom_config.gen_ssh_key_pair | bool - ssh_key_pair.changed - name: clone or update private git repository @@ -37,12 +37,12 @@ block: - name: try to download/update git repo ansible.builtin.git: - repo: "{{ weechat.custom_config.private_repo }}" - dest: "{{ weechat.home_directory }}/.weechat" - version: "{{ weechat.custom_config.version | default ('main') }}" + repo: "{{ weechat__custom_private_repo }}" + dest: "{{ weechat__home_directory }}/.weechat" + version: "{{ weechat__custom_config.version | default ('main') }}" accept_hostkey: true update: true - ssh_opts: "-i {{ weechat.home_directory }}/.ssh/id_ed25519" + ssh_opts: "-i {{ weechat__home_directory }}/.ssh/id_ed25519" rescue: - name: wait until you fixed remote git issues pause: @@ -50,18 +50,18 @@ - name: try to download/update git repo again ansible.builtin.git: - repo: "{{ weechat.custom_config.private_repo }}" - dest: "{{ weechat.home_directory }}/.weechat" - version: master + repo: "{{ weechat__custom_private_repo }}" + dest: "{{ weechat__home_directory }}/.weechat" + version: "{{ weechat__custom_config.version | default ('main') }}" accept_hostkey: true update: true - ssh_opts: "-i {{ weechat.home_directory }}/.ssh/id_ed25519" - when: not weechat.custom_config.private_repo | bool + ssh_opts: "-i {{ weechat__home_directory }}/.ssh/id_ed25519" + when: not weechat__custom_private_repo | bool -- name: "change git repo ownwe to {{ weechat.user }}" +- name: "change git repo ownwe to {{ weechat__user }}" become: true ansible.builtin.file: - path: "{{ weechat.home_directory }}/.weechat" + path: "{{ weechat__home_directory }}/.weechat" recurse: true - owner: "{{ weechat.user }}" - when: not weechat.custom_config.private_repo | bool + owner: "{{ weechat__user }}" + when: not weechat__custom_private_repo | bool diff --git a/tasks/configure_plugins.yml b/tasks/configure_plugins.yml index 777a808..d93b7f5 100644 --- a/tasks/configure_plugins.yml +++ b/tasks/configure_plugins.yml @@ -2,29 +2,29 @@ - name: create weechat directory become: true file: - path: "{{ weechat.home_directory }}/.weechat" + path: "{{ weechat__home_directory }}/.weechat" state: directory - owner: "{{ weechat.user }}" + owner: "{{ weechat__user }}" mode: "0750" - name: create weechat plugins directory become: true file: - path: "{{ weechat.home_directory }}/.weechat/{{ item.value }}/autoload" + path: "{{ weechat__home_directory }}/.weechat/{{ item.value }}/autoload" state: directory - owner: "{{ weechat.user }}" + owner: "{{ weechat__user }}" mode: "0750" with_dict: "{{ weechat_plugin_languages }}" - name: download weechat plugins get_url: url: 'https://weechat.org/files/scripts/{{ item }}' - dest: "{{ weechat.home_directory }}/.weechat/{{ weechat_plugin_languages[item.split('.',1)[-1]] }}/{{ item }}" - with_items: '{{ weechat.plugins }}' + dest: "{{ weechat__home_directory }}/.weechat/{{ weechat_plugin_languages[item.split('.',1)[-1]] }}/{{ item }}" + with_items: '{{ weechat__plugins }}' - name: symlinking plugins to autoload file: - src: "{{ weechat.home_directory }}/.weechat/{{ weechat_plugin_languages[item.split('.',1)[-1]] }}/{{ item }}" - dest: "{{ weechat.home_directory }}/.weechat/{{ weechat_plugin_languages[item.split('.',1)[-1]] }}/autoload/{{ item }}" + src: "{{ weechat__home_directory }}/.weechat/{{ weechat_plugin_languages[item.split('.',1)[-1]] }}/{{ item }}" + dest: "{{ weechat__home_directory }}/.weechat/{{ weechat_plugin_languages[item.split('.',1)[-1]] }}/autoload/{{ item }}" state: link - with_items: '{{ weechat.plugins }}' + with_items: '{{ weechat__plugins }}' diff --git a/tasks/install-debian.yml b/tasks/install-debian.yml index dadbf9e..8660eab 100644 --- a/tasks/install-debian.yml +++ b/tasks/install-debian.yml @@ -9,7 +9,7 @@ become: true ansible.builtin.apt_key: keyserver: 'keys.openpgp.org' - id: "{{ weechat.gpg_id }}" + id: "{{ weechat__gpg_id }}" state: present - name: add weechat repo diff --git a/tasks/main.yml b/tasks/main.yml index 1fdd62e..88cdc39 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,24 +1,20 @@ --- -- name: combine weechat variables - set_fact: - weechat: "{{ _weechat | combine(weechat, recursive=True) }}" - - name: perform optinal versionscheck ansible.builtin.include_tasks: versioncheck.yml when: submodules_versioncheck|bool - name: install weechat ansible.builtin.include_tasks: "install-{{ ansible_os_family|lower }}.yml" - when: weechat.install | bool + when: weechat__install | bool -- name: deploy weechat configuration +- name: deploy weechat__configuration ansible.builtin.include_tasks: configure_custom_config.yml - when: weechat.use_custom_config | bool + when: weechat__use_custom_config | bool -- name: install requirements for weechat plugins +- name: install requirements for weechat__plugins ansible.builtin.include_tasks: configure_plugins.yml - when: weechat.install_plugins | bool + when: weechat__install_plugins | bool -- name: setup weechat autostart +- name: setup weechat__autostart ansible.builtin.include_tasks: setup_autostart.yml - when: weechat.autostart | bool + when: weechat__autostart | bool diff --git a/tasks/setup_autostart.yml b/tasks/setup_autostart.yml index dddaae1..91dee16 100644 --- a/tasks/setup_autostart.yml +++ b/tasks/setup_autostart.yml @@ -4,7 +4,7 @@ ansible.builtin.package: name: tmux state: present - when: weechat.install | bool + when: weechat__install | bool - name: copy systemd service for weechat become: true diff --git a/templates/weechat.service b/templates/weechat.service index ac59319..27ad8d9 100644 --- a/templates/weechat.service +++ b/templates/weechat.service @@ -2,7 +2,7 @@ Description=Weechat Chat Client [Service] -User={{ weechat.user }} +User={{ weechat__user }} Type=oneshot RemainAfterExit=yes ExecStart=/usr/bin/tmux -2 new-session -d -s weechat /usr/bin/weechat diff --git a/vars/main.yml b/vars/main.yml index 8a1485e..67f7c35 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -9,21 +9,7 @@ weechat_plugin_languages: lua: lua # version management -playbook_version_number: 4200 # should be over ninethousand +playbook_version_number: 4220 # should be over ninethousand playbook_version_path: 'role-weechat_roles-ansible_github.com.version' -# default values -_weechat: - install: true - autostart: false - install_plugins: false - user: "{{ ansible_user_id }}" - home_directory: "{{ ansible_env.HOME | default('/home/{{ weechat.user }}') }}" - plugins: [] - gpg_id: '11E9DE8848F2B65222AA75B8D1820DB22A11534E' - use_custom_config: false - custom_config: - private_repo: false - gen_ssh_key_pair: true - weechat__debian_weechat_repo: "https://weechat.org/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} main"