1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_weechat.git synced 2024-08-16 13:09:48 +02:00

Merge pull request #11 from roles-ansible/apt

improve apt, linting, actions and update
This commit is contained in:
L3D 2023-10-30 00:23:01 +01:00 committed by GitHub
commit 2d7fba3084
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 143 additions and 77 deletions

View file

@ -10,14 +10,14 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: 'checkout git repo' - name: Checkout git repo
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
lfs: true submodules: true
submodules: false
fetch-depth: 0 fetch-depth: 0
- name: 'Lint Ansible Playbook' - name: Run ansible-lint
uses: ansible/ansible-lint-action@v6 uses: ansible-actions/ansible-lint-action@v1.0.2
with: with:
path: "." target: "./"
collections_yml: 'requirements.yml'

View file

@ -1,22 +1,24 @@
--- ---
name: Galaxy release name: Galaxy-NG Roles Import
# yamllint disable-line rule:truthy # yamllint disable-line rule:truthy
on: on:
push:
branches: ['main']
release: release:
types: ['created'] types: ['created']
jobs: jobs:
build: build:
name: Galaxy Role Importer
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps:
- name: 'checkout git repo'
uses: actions/checkout@v4
- name: 'release on galaxy' steps:
uses: robertdebock/galaxy-action@1.2.1 - name: 'Checkout git repo'
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: 'Release on galaxy'
uses: ansible-actions/ansible-galaxy-action@v1.1.1
with: with:
galaxy_api_key: ${{ secrets.galaxy_api_key }} galaxy_api_key: ${{ secrets.galaxy_api_key }}
git_branch: 'main'

22
.github/workflows/j2lint-check.yml vendored Normal file
View file

@ -0,0 +1,22 @@
---
name: Jinja2 Linting check
# yamllint disable-line rule:truthy
on: [push, pull_request]
jobs:
build:
name: Jinja2 Linting
runs-on: ubuntu-latest
steps:
- name: Checkout git repo
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Run j2lint
uses: ansible-actions/j2lint-action@v0.0.1
with:
target: "./"

22
.github/workflows/yamllint-check.yml vendored Normal file
View file

@ -0,0 +1,22 @@
---
name: Yamllint check
# yamllint disable-line rule:truthy
on: [push, pull_request]
jobs:
build:
name: Yamllint
runs-on: ubuntu-latest
steps:
- name: Checkout git repo
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Run yamllint
uses: ansible-actions/yamllint-action@v0.0.1
with:
target: "./"

View file

@ -1,23 +0,0 @@
---
name: 'Yamllint GitHub Actions'
# yamllint disable-line rule:truthy
on:
push:
branches: '*'
pull_request:
branches: '*'
jobs:
yamllint:
name: 'Yamllint'
runs-on: ubuntu-latest
steps:
- name: 'checkout git repo'
uses: actions/checkout@v4
- name: 'Yamllint'
uses: karancode/yamllint-github-action@v2.1.1
with:
yamllint_file_or_dir: '.'
yamllint_config_filepath: './.yamllint'

View file

@ -95,6 +95,12 @@ weechat__custom_version: main
+ 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. + 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). + 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).
## Requirements
The ``community.general`` and ``community.crypto`` collections are required for some parts of this ansible role.
You can install it with this command:
```bash
ansible-galaxy collection install -r requirements.yml --upgrade
```
Contribute 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. 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.

6
requirements.yml Normal file
View file

@ -0,0 +1,6 @@
---
collections:
- name: 'community.general'
version: ">=7.5.0,<=8.0.0"
- name: 'community.crypto'
version: ">=2.15.1,<=3.0.0"

View file

@ -1,9 +1,9 @@
--- ---
- name: Create ssh key pair (if needed) - name: Create ssh key pair (if needed) # noqa: H1901
become: true become: true
community.crypto.openssh_keypair: community.crypto.openssh_keypair:
path: "{{ weechat__home_directory }}/.ssh/id_ed25519" path: "{{ weechat__home_directory }}/.ssh/id_ed25519"
type: ed25519 type: 'ed25519'
owner: "{{ weechat__user }}" owner: "{{ weechat__user }}"
register: ssh_key_pair register: ssh_key_pair
when: weechat__custom_gen_ssh_key_pair | bool when: weechat__custom_gen_ssh_key_pair | bool
@ -32,7 +32,7 @@
- weechat__custom_gen_ssh_key_pair | bool - weechat__custom_gen_ssh_key_pair | bool
- ssh_key_pair.changed - ssh_key_pair.changed
- name: Add git repo to save.directory globally for root - name: Add git repo to save.directory globally for root # noqa: H1901
become: true become: true
community.general.git_config: community.general.git_config:
name: safe.directory name: safe.directory
@ -40,7 +40,7 @@
value: "{{ weechat__home_directory }}/.weechat" value: "{{ weechat__home_directory }}/.weechat"
register: save_directory register: save_directory
- name: "Add git repo to save.directory globally for {{ weechat__user }}" - name: "Add git repo to save.directory globally for {{ weechat__user }}" # noqa: H1901
become: true become: true
community.general.git_config: community.general.git_config:
file: "{{ weechat__home_directory }}/.gitconfig" file: "{{ weechat__home_directory }}/.gitconfig"
@ -55,6 +55,7 @@
path: "{{ weechat__home_directory }}/.gitconfig" path: "{{ weechat__home_directory }}/.gitconfig"
recurse: false recurse: false
owner: "{{ weechat__user }}" owner: "{{ weechat__user }}"
mode: 'u=rwX,g=rX,o='
changed_when: save_user_directory.changed | bool changed_when: save_user_directory.changed | bool
- name: "Change git repo owner to root" - name: "Change git repo owner to root"
@ -63,6 +64,8 @@
path: "{{ weechat__home_directory }}/.weechat" path: "{{ weechat__home_directory }}/.weechat"
recurse: true recurse: true
owner: "root" owner: "root"
group: 'root'
mode: 'u=rwX,g=rX,o='
changed_when: ssh_key_pair.changed | bool or save_directory.changed | bool changed_when: ssh_key_pair.changed | bool or save_directory.changed | bool
when: not weechat__custom_private_repo | bool when: not weechat__custom_private_repo | bool
@ -98,5 +101,7 @@
path: "{{ weechat__home_directory }}/.weechat" path: "{{ weechat__home_directory }}/.weechat"
recurse: true recurse: true
owner: "{{ weechat__user }}" owner: "{{ weechat__user }}"
group: 'root'
mode: 'u=rwX,g=rX,o='
changed_when: ssh_key_pair.changed | bool or save_directory.changed | bool changed_when: ssh_key_pair.changed | bool or save_directory.changed | bool
when: not weechat__custom_private_repo | bool when: not weechat__custom_private_repo | bool

View file

@ -21,11 +21,13 @@
url: 'https://weechat.org/files/scripts/{{ item }}' url: 'https://weechat.org/files/scripts/{{ item }}'
dest: "{{ weechat__home_directory }}/.weechat/{{ weechat_plugin_languages[item.split('.', 1)[-1]] }}/{{ item }}" dest: "{{ weechat__home_directory }}/.weechat/{{ weechat_plugin_languages[item.split('.', 1)[-1]] }}/{{ item }}"
mode: '0644' mode: '0644'
with_items: '{{ weechat__plugins }}' loop: '{{ weechat__plugins }}'
- name: Symlinking plugins to autoload - name: Symlinking plugins to autoload
ansible.builtin.file: ansible.builtin.file:
src: "{{ weechat__home_directory }}/.weechat/{{ weechat_plugin_languages[item.split('.', 1)[-1]] }}/{{ 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 }}" dest: "{{ weechat__home_directory }}/.weechat/{{ weechat_plugin_languages[item.split('.', 1)[-1]] }}/autoload/{{ item }}"
state: link state: link
with_items: '{{ weechat__plugins }}' mode: 0644
owner: root
loop: '{{ weechat__plugins }}'

View file

@ -10,41 +10,61 @@
- name: Install apt-transport-https - name: Install apt-transport-https
become: true become: true
ansible.builtin.apt: ansible.builtin.apt:
name: name: "{{ item }}"
- apt-transport-https state: 'present'
- gpg loop:
state: present - 'apt-transport-https'
- 'gpg'
- name: Add weechat repository gpg-key - name: Add weechat repository gpg-key
become: true become: true
ansible.builtin.apt_key: ansible.builtin.apt_key:
keyserver: 'keys.openpgp.org' keyserver: 'keys.openpgp.org'
id: "{{ weechat__gpg_id }}" id: "{{ weechat__gpg_id }}"
state: present state: 'present'
- name: Create /usr/share/keyrings directory
become: true
ansible.builtin.file:
path: '/usr/share/keyrings'
state: 'directory'
owner: 'root'
group: 'root'
mode: '0755'
- name: Import WeeChat GPG key
become: true
ansible.builtin.get_url:
url: "https://keys.openpgp.org/vks/v1/by-fingerprint/{{ weechat__gpg_id }}"
dest: '/usr/share/keyrings/weechat-archive-keyring.gpg'
owner: 'root'
group: 'root'
mode: '0644'
- name: Add weechat repo - name: Add weechat repo
become: true become: true
ansible.builtin.apt_repository: ansible.builtin.apt_repository:
repo: "deb {{ weechat__debian_weechat_repo }}" repo: "deb [signed-by=/usr/share/keyrings/weechat-archive-keyring.gpg] {{ weechat__debian_weechat_repo }}"
state: present state: 'present'
update_cache: true update_cache: true
- name: Add weechat repo-src - name: Add weechat repo-src
become: true become: true
ansible.builtin.apt_repository: ansible.builtin.apt_repository:
repo: "deb-src {{ weechat__debian_weechat_repo }}" repo: "deb-src [signed-by=/usr/share/keyrings/weechat-archive-keyring.gpg] {{ weechat__debian_weechat_repo }}"
state: present state: 'present'
update_cache: true update_cache: true
- name: Install recomended weechat packages - name: Install recomended weechat packages
become: true become: true
ansible.builtin.apt: ansible.builtin.apt:
name: name: "{{ item }}"
- weechat-curses state: 'present'
- weechat-plugins loop:
- weechat-python - 'weechat-curses'
- weechat-perl - 'weechat-plugins'
- weechat-lua - 'weechat-python'
- weechat-ruby - 'weechat-perl'
- weechat-doc - 'weechat-lua'
state: present - 'weechat-ruby'
- 'weechat-doc'

View file

@ -1,20 +1,25 @@
--- ---
- name: Perform optinal versionscheck - name: Perform optinal versionscheck
ansible.builtin.include_tasks: versioncheck.yml ansible.builtin.include_tasks:
file: 'versioncheck.yml'
when: submodules_versioncheck | bool when: submodules_versioncheck | bool
- name: Install weechat - name: 'Install weechat'
ansible.builtin.include_tasks: "install-{{ ansible_os_family | lower }}.yml" ansible.builtin.include_tasks:
file: "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 ansible.builtin.include_tasks:
file: 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 ansible.builtin.include_tasks:
file: 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 ansible.builtin.include_tasks:
file: setup_autostart.yml
when: weechat__autostart | bool when: weechat__autostart | bool

View file

@ -7,7 +7,7 @@
ansible.builtin.file: ansible.builtin.file:
path: '/etc/.ansible-version' path: '/etc/.ansible-version'
state: directory state: directory
mode: 0755 mode: '0755'
when: submodules_versioncheck | bool when: submodules_versioncheck | bool
- name: Check playbook version - name: Check playbook version
@ -16,15 +16,14 @@
src: "/etc/.ansible-version/{{ playbook_version_path }}" src: "/etc/.ansible-version/{{ playbook_version_path }}"
register: playbook_version register: playbook_version
when: submodules_versioncheck | bool when: submodules_versioncheck | bool
ignore_errors: true
failed_when: false failed_when: false
- name: Print remote role version - name: Print remote role version # noqa: H500
ansible.builtin.debug: ansible.builtin.debug:
msg: "Remote role version: {{ playbook_version.content | default('Y3VycmVudGx5IG5vdCBkZXBsb3llZAo=') | b64decode | string }}" msg: "Remote role version: {{ playbook_version.content | default('Y3VycmVudGx5IG5vdCBkZXBsb3llZAo=') | b64decode | string }}"
when: submodules_versioncheck | bool when: submodules_versioncheck | bool
- name: Print locale role version - name: Print locale role version # noqa: H500
ansible.builtin.debug: ansible.builtin.debug:
msg: "Local role version: '{{ playbook_version_number | string }}'." msg: "Local role version: '{{ playbook_version_number | string }}'."
when: submodules_versioncheck | bool when: submodules_versioncheck | bool

View file

@ -9,7 +9,7 @@ weechat_plugin_languages:
lua: 'lua' lua: 'lua'
# version management # version management
playbook_version_number: 4223 # should be over ninethousand playbook_version_number: 4224 # should be over ninethousand
playbook_version_path: 'role-weechat_roles-ansible_github.com.version' playbook_version_path: 'role-weechat_roles-ansible_github.com.version'
weechat__debian_weechat_repo: "https://weechat.org/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} main" weechat__debian_weechat_repo: "https://weechat.org/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} main"