From ae6e1dacdd9ec02d69ff1a3b3783c31d78989590 Mon Sep 17 00:00:00 2001 From: L3D Date: Wed, 11 Mar 2020 21:12:00 +0100 Subject: [PATCH 1/7] start custom weechat config --- defaults/main.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index 8a5c863..008b532 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -6,6 +6,8 @@ weechat: autostart: false # should we install official weechat plugins install_plugins: false + # custom weechat config (requires some manual interaction for long-term usage) + custom # user to install and use weechat user: "{{ ansible_user_id }}" # where is our home direcotory for weechat @@ -14,7 +16,12 @@ weechat: plugins: [] # weechat gpg key for debian/ubuntu repo gpg_id: '11E9DE8848F2B65222AA75B8D1820DB22A11534E' - + # custom private config + costom_config: + # path to your custom weechat config (with plugins) git repo ( git@github.com:/.git ) + private_repo: false + # generate ssh key pair (if not available) + gen_ssh_key_pair: true # version check for this role? (true is recomended) submodules_versioncheck: false From 74fe2f3bf0807bc2c5dd0446984e6679036b9e01 Mon Sep 17 00:00:00 2001 From: L3D Date: Wed, 11 Mar 2020 22:49:18 +0100 Subject: [PATCH 2/7] start docs --- README.md | 49 +++++++++++++++++++++++++++++++++++++++++++++++ defaults/main.yml | 2 +- vars/main.yml | 5 +++++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a7ec8f7..168a744 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,55 @@ Ansible role to install and configure weechat. - ~~configure weechat~~ *(in progress)* - autostart via tmux and systemd + Settings +---------- + +```yaml + weechat: + install: true +``` ++ ``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. ++ ``install: false``: We do not install weechat + +```yaml +weechat: + autostart: false +``` ++ ``autostart: false``: We do not install any autostart mechanism ++ ``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 +``` ++ ``install_plugins: false``: we do not install any weechat plugins ++ ``install_plugins: true``: We do install all official plugins specified in ``{{ weecat.plugins }}`` dict. + +```yaml +weechat: + use_custom_config: false +``` + + 7 │ # should we install official weechat plugins + 8 │ install_plugins: false + 9 │ # custom weechat config (requires some manual interaction for long-term usage) + 10 │ custom + 11 │ # user to install and use weechat + 12 │ user: "{{ ansible_user_id }}" + 13 │ # where is our home direcotory for weechat + 14 │ home_directory: "{{ ansible_env.HOME | default('/home/{{ weechat.user }}') }}/.weechat" + 15 │ # plugins we want + 16 │ plugins: [] + 17 │ # weechat gpg key for debian/ubuntu repo + 18 │ gpg_id: '11E9DE8848F2B65222AA75B8D1820DB22A11534E' + 19 │ # custom private config + 20 │ costom_config: + 21 │ # path to your custom weechat config (with plugins) git repo ( git@github.com:/.git ) + 22 │ private_repo: false + 23 │ # generate ssh key pair (if not available) + 24 │ gen_ssh_key_pair: true + + ```txt WARNING diff --git a/defaults/main.yml b/defaults/main.yml index 008b532..f21f3e8 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -7,7 +7,7 @@ weechat: # should we install official weechat plugins install_plugins: false # custom weechat config (requires some manual interaction for long-term usage) - custom + use_custom_config: false # user to install and use weechat user: "{{ ansible_user_id }}" # where is our home direcotory for weechat diff --git a/vars/main.yml b/vars/main.yml index 76e8b29..9edf3b6 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -21,3 +21,8 @@ _weechat: home_directory: "{{ ansible_env.HOME | default('/home/{{ weechat.user }}') }}/.weechat" plugins: [] gpg_id: '11E9DE8848F2B65222AA75B8D1820DB22A11534E' + use_custom_config: false + costom_config: + private_repo: false + gen_ssh_key_pair: true + From f9cd418da381c72bb0a98899841a22c67c1167af Mon Sep 17 00:00:00 2001 From: L3D Date: Thu, 12 Mar 2020 03:42:12 +0100 Subject: [PATCH 3/7] Explain variables in the README --- README.md | 98 +++++++++++++++++++++++++++++++++-------------- defaults/main.yml | 2 +- vars/main.yml | 4 +- 3 files changed, 73 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 168a744..1c3a5ff 100644 --- a/README.md +++ b/README.md @@ -18,48 +18,80 @@ Ansible role to install and configure weechat. weechat: install: true ``` -+ ``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. -+ ``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 +```yaml weechat: autostart: false ``` -+ ``autostart: false``: We do not install any autostart mechanism -+ ``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 ``` -+ ``install_plugins: false``: we do not install any weechat plugins -+ ``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``: 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 - 7 │ # should we install official weechat plugins - 8 │ install_plugins: false - 9 │ # custom weechat config (requires some manual interaction for long-term usage) - 10 │ custom - 11 │ # user to install and use weechat - 12 │ user: "{{ ansible_user_id }}" - 13 │ # where is our home direcotory for weechat - 14 │ home_directory: "{{ ansible_env.HOME | default('/home/{{ weechat.user }}') }}/.weechat" - 15 │ # plugins we want - 16 │ plugins: [] - 17 │ # weechat gpg key for debian/ubuntu repo - 18 │ gpg_id: '11E9DE8848F2B65222AA75B8D1820DB22A11534E' - 19 │ # custom private config - 20 │ costom_config: - 21 │ # path to your custom weechat config (with plugins) git repo ( git@github.com:/.git ) - 22 │ private_repo: false - 23 │ # generate ssh key pair (if not available) - 24 │ gen_ssh_key_pair: true +```yaml +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. +```yaml +weechat: + plugins: + - go.py + - iset.pl +``` ++ Example ``weechat.plugins: []`` list +```yaml +weechat: + user: "{{ ansible_user_id }}" +``` ++ the user to use weechat with. This value is used in the ``autostart`` task and the ``{{ weechat.home_directory }}`` variable + +```yaml +weechat: + home_directory: "{{ ansible_env.HOME | default('/home/{{ weechat.user }}') }}/.weechat" +``` ++ 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. ++ it points in the ``.weechat`` directory of your home. + +```yaml +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 +``` ++ The path to your git repo with your personal weechat config. ++ This role clones the repo to the ``{{ weechat.home_directory }}`` destination. *(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_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. ```txt WARNING @@ -67,14 +99,24 @@ WARNING It is work-in-progress. Be careful! MISSING -- task for configurations +- all task for configurations - testing for all OS -- docs +- improved docs - galaxy ``` References and Inspiration: ---------------------- + Information about installation on debian/ubuntu can be found at [weechat.org/download/debian](https://weechat.org/download/debian/) - + Some parts of the Weechat configuration is inspired by [github.com/irth/ansible-role-weechat](https://github.com/irth/ansible-role-weechat.git) but written in a complete different way. + + Some parts of the Weechat configuration is inspired by [github.com/irth/ansible-role-weechat](https://github.com/irth/ansible-role-weechat.git) but written in a complete different way. Some other is completly different. + Autostart and systemd is inspired by [ubuntu wiki](https://wiki.ubuntuusers.de/Howto/systemd_Service_Unit_Beispiel/) and [ansible docs](https://docs.ansible.com/ansible/latest/modules/systemd_module.html). + + Contribute +------------ +If you missing a feature, found a bug or have questions about this role please feel free to open a git issue. Or - even better - create a pull request. + + LICENSE +---------- +[MIT License](https://github.com/chaos-bodensee/role_weechat/blob/master/LICENSE)
++ ``Copyright (c) 2019 L3D`` ++ The complete list of awesome contributros can be found [here](https://github.com/chaos-bodensee/role_weechat/graphs/contributors). diff --git a/defaults/main.yml b/defaults/main.yml index f21f3e8..0f68ba4 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -17,7 +17,7 @@ weechat: # weechat gpg key for debian/ubuntu repo gpg_id: '11E9DE8848F2B65222AA75B8D1820DB22A11534E' # custom private config - costom_config: + custom_config: # path to your custom weechat config (with plugins) git repo ( git@github.com:/.git ) private_repo: false # generate ssh key pair (if not available) diff --git a/vars/main.yml b/vars/main.yml index 9edf3b6..db5cfbc 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -9,7 +9,7 @@ weechat_plugin_languages: lua: lua # version management -playbook_version_number: 2055 # should be over ninethousand +playbook_version_number: 2056 # should be over ninethousand playbook_version_path: 'role-weechat_roles-ansible_github.com.version' # default values @@ -22,7 +22,7 @@ _weechat: plugins: [] gpg_id: '11E9DE8848F2B65222AA75B8D1820DB22A11534E' use_custom_config: false - costom_config: + custom_config: private_repo: false gen_ssh_key_pair: true From 42cd710101c8129dbbac5b72b4d3e5ebeae3a546 Mon Sep 17 00:00:00 2001 From: L3D Date: Thu, 12 Mar 2020 04:01:23 +0100 Subject: [PATCH 4/7] start creating ssh key creation for custom config --- README.md | 2 +- tasks/configure_custom_config.yml | 16 ++++++++++++++++ tasks/main.yml | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tasks/configure_custom_config.yml diff --git a/README.md b/README.md index 1c3a5ff..75f237f 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ weechat: weechat: user: "{{ ansible_user_id }}" ``` -+ the user to use weechat with. This value is used in the ``autostart`` 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: diff --git a/tasks/configure_custom_config.yml b/tasks/configure_custom_config.yml new file mode 100644 index 0000000..be84512 --- /dev/null +++ b/tasks/configure_custom_config.yml @@ -0,0 +1,16 @@ +--- +- name: create ssh key pair (if needed) + become: true + become_user: "{{ weechat.user }}" + openssh_keypair: + path: "{{ weechat.home_directory }}/../.ssh/id_ed25519" + type: ed25519 + register: ssh_key_pair + when: weechat.custom_config.gen_ssh_key_pair | bool + +- name: print ssh public key to user + pause: + prompt: "Your ssh public key:\n\n{{ ssh_key_pair.public_key }}\n\n" + when: + - weechat.custom_config.gen_ssh_key_pair | bool + - ssh_key_pair.changed diff --git a/tasks/main.yml b/tasks/main.yml index b805a49..5000d4d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -9,6 +9,9 @@ - include_tasks: "install-{{ ansible_os_family|lower }}.yml" when: weechat.install | bool +- include_tasks: configure_custom_config.yml + when: weechat.use_custom_config | bool + - include_tasks: configure_plugins.yml when: weechat.install_plugins | bool From 82181b0829141a6ce0e65d362a1eb78edabbb3f5 Mon Sep 17 00:00:00 2001 From: L3D Date: Thu, 12 Mar 2020 04:37:54 +0100 Subject: [PATCH 5/7] improve creating ssh key creation for custom config --- tasks/configure_custom_config.yml | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/tasks/configure_custom_config.yml b/tasks/configure_custom_config.yml index be84512..b7d562b 100644 --- a/tasks/configure_custom_config.yml +++ b/tasks/configure_custom_config.yml @@ -1,16 +1,35 @@ --- - name: create ssh key pair (if needed) - become: true become_user: "{{ weechat.user }}" + become: true openssh_keypair: path: "{{ weechat.home_directory }}/../.ssh/id_ed25519" type: ed25519 + owner: "{{ weechat.user }}" register: ssh_key_pair when: weechat.custom_config.gen_ssh_key_pair | bool - name: print ssh public key to user pause: - prompt: "Your ssh public key:\n\n{{ ssh_key_pair.public_key }}\n\n" + prompt: | + We generated a new ssh key pair for you. + Please use the following public key as deployment key + to your private git repository with your own weechat config. + + Private git repositorys are not public available and + you need some sort of authorisation method to verify + that you are allowed to clone your private repo. + + Your ssh public key come here... + + + {{ ssh_key_pair.public_key }} + + + Please be aware, that this role do not commit or + push any local changes and you have to do this + manually by yourself. + when: - weechat.custom_config.gen_ssh_key_pair | bool - ssh_key_pair.changed From d8b52131c056aeef8586b80a84ca24e0b92d36bf Mon Sep 17 00:00:00 2001 From: L3D Date: Thu, 12 Mar 2020 22:44:15 +0100 Subject: [PATCH 6/7] clone private weechat repo --- tasks/configure_custom_config.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tasks/configure_custom_config.yml b/tasks/configure_custom_config.yml index b7d562b..d718278 100644 --- a/tasks/configure_custom_config.yml +++ b/tasks/configure_custom_config.yml @@ -29,7 +29,15 @@ Please be aware, that this role do not commit or push any local changes and you have to do this manually by yourself. - when: - weechat.custom_config.gen_ssh_key_pair | bool - ssh_key_pair.changed + +- name: clone private git repository + become_user: "{{ weechat.user }}" + become: true + git: + repo: "{{ weechat.custom_config.private_repo }}" + dest: "{{ weechat.home_directory }}" + version: master + when: not weechat.custom_config.private_repo | bool From 15abdf974c0f8b9a6c0654b059f5ad1b1f62c5b7 Mon Sep 17 00:00:00 2001 From: L3D Date: Thu, 12 Mar 2020 23:03:29 +0100 Subject: [PATCH 7/7] Add repo checkout --- README.md | 7 +++---- defaults/main.yml | 2 +- tasks/configure_custom_config.yml | 5 +++-- tasks/configure_plugins.yml | 10 +++++----- vars/main.yml | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 75f237f..a556df4 100644 --- a/README.md +++ b/README.md @@ -65,10 +65,9 @@ weechat: ```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. -+ it points in the ``.weechat`` directory of your home. ```yaml weechat: @@ -82,7 +81,7 @@ weechat: private_repo: false ``` + The path to your git repo with your personal weechat config. -+ This role clones the repo to the ``{{ weechat.home_directory }}`` destination. *(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 @@ -90,7 +89,7 @@ weechat: custom_config: 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: 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. ```txt diff --git a/defaults/main.yml b/defaults/main.yml index 0f68ba4..4d59c8d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -11,7 +11,7 @@ weechat: # user to install and use 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 gpg key for debian/ubuntu repo diff --git a/tasks/configure_custom_config.yml b/tasks/configure_custom_config.yml index d718278..8e3224e 100644 --- a/tasks/configure_custom_config.yml +++ b/tasks/configure_custom_config.yml @@ -3,7 +3,7 @@ become_user: "{{ weechat.user }}" become: true openssh_keypair: - path: "{{ weechat.home_directory }}/../.ssh/id_ed25519" + path: "{{ weechat.home_directory }}/.ssh/id_ed25519" type: ed25519 owner: "{{ weechat.user }}" register: ssh_key_pair @@ -38,6 +38,7 @@ become: true git: repo: "{{ weechat.custom_config.private_repo }}" - dest: "{{ weechat.home_directory }}" + dest: "{{ weechat.home_directory }}/.weechat" version: master + accept_hostkey: yes when: not weechat.custom_config.private_repo | bool diff --git a/tasks/configure_plugins.yml b/tasks/configure_plugins.yml index be0e488..b1d030d 100644 --- a/tasks/configure_plugins.yml +++ b/tasks/configure_plugins.yml @@ -3,7 +3,7 @@ become: true become_user: "{{ weechat.user }}" file: - path: "{{ weechat.home_directory }}" + path: "{{ weechat.home_directory }}/.weechat" state: directory owner: "{{ weechat.user }}" mode: "0750" @@ -12,7 +12,7 @@ become: true become_user: "{{ weechat.user }}" file: - path: "{{ weechat.home_directory }}/{{ item.value }}/autoload" + path: "{{ weechat.home_directory }}/.weechat/{{ item.value }}/autoload" state: directory owner: "{{ weechat.user }}" mode: "0750" @@ -21,12 +21,12 @@ - name: download weechat plugins get_url: url: 'https://weechat.org/files/scripts/{{ item }}' - dest: "{{ weechat.home_directory }}/{{ weechat_plugin_languages[item.split('.',1)[-1]] }}/{{ item }}" + 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_plugin_languages[item.split('.',1)[-1]] }}/{{ item }}" - dest: "{{ weechat.home_directory }}/{{ 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 }}' diff --git a/vars/main.yml b/vars/main.yml index db5cfbc..aa6bbc3 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -18,7 +18,7 @@ _weechat: autostart: false install_plugins: false user: "{{ ansible_user_id }}" - home_directory: "{{ ansible_env.HOME | default('/home/{{ weechat.user }}') }}/.weechat" + home_directory: "{{ ansible_env.HOME | default('/home/{{ weechat.user }}') }}" plugins: [] gpg_id: '11E9DE8848F2B65222AA75B8D1820DB22A11534E' use_custom_config: false