diff --git a/.github/workflows/ansible-linting-check.yml b/.github/workflows/ansible-linting-check.yml index 4d7dc8e..150e908 100644 --- a/.github/workflows/ansible-linting-check.yml +++ b/.github/workflows/ansible-linting-check.yml @@ -10,6 +10,7 @@ on: jobs: build: + runs-on: ubuntu-latest steps: diff --git a/README.md b/README.md index c6318f1..7c15121 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -[![Ansible Galaxy](https://raw.githubusercontent.com/chaos-bodensee/role_weechat/master/.github/galaxy.svg?sanitize=true)](https://galaxy.ansible.com/do1jlr/weechat) [![MIT License](https://raw.githubusercontent.com/chaos-bodensee/role_weechat/master/.github/license.svg?sanitize=true)](https://github.com/chaos-bodensee/role_weechat/blob/master/LICENSE) +[![Ansible Galaxy](https://raw.githubusercontent.com/roles-ansible/ansible_role_weechat/main/.github/galaxy.svg)](https://galaxy.ansible.com/do1jlr/weechat) +[![MIT License](https://raw.githubusercontent.com/roles-ansible/ansible_role_weechat/main/.github/license.svg?sanitize=true)](https://github.com/roles-ansible/ansible_role_weechat/blob/main/LICENSE) ansible weechat role ========================== diff --git a/handlers/main.yml b/handlers/main.yml index 46b55cb..f30ef67 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,5 +1,5 @@ --- -- name: systemctl restart weechat.service +- name: Run systemctl restart weechat.service become: true ansible.builtin.systemd: state: restarted diff --git a/meta/main.yml b/meta/main.yml index 1b7d539..84d343a 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -4,18 +4,19 @@ galaxy_info: author: do1jlr description: Install and optional configure weechat via ansible license: "MIT" - min_ansible_version: 2.11 - github_branch: main + min_ansible_version: '2.14' platforms: - - name: Archlinux - versions: all - - name: Debian - versions: all - - name: Ubuntu - versions: all - - name: Fedora - versions: all + - name: 'ArchLinux' + versions: ['all'] + - name: 'Debian' + versions: ['all'] + - name: 'Ubuntu' + versions: ['all'] + - name: 'Fedora' + versions: ['all'] galaxy_tags: - weechat - irc + - chat + - textmessages dependencies: [] diff --git a/tasks/configure_custom_config.yml b/tasks/configure_custom_config.yml index 5d8f61b..43d93c7 100644 --- a/tasks/configure_custom_config.yml +++ b/tasks/configure_custom_config.yml @@ -1,5 +1,5 @@ --- -- name: create ssh key pair (if needed) +- name: Create ssh key pair (if needed) become: true community.crypto.openssh_keypair: path: "{{ weechat__home_directory }}/.ssh/id_ed25519" @@ -8,7 +8,7 @@ register: ssh_key_pair when: weechat__custom_gen_ssh_key_pair | bool -- name: print ssh public key to user +- name: Print ssh public key to user ansible.builtin.pause: prompt: | We generated a new ssh key pair for you. @@ -32,36 +32,46 @@ - weechat__custom_gen_ssh_key_pair | bool - ssh_key_pair.changed -- name: clone or update private git repository +- name: "Change git repo owner to root" become: true + ansible.builtin.file: + path: "{{ weechat__home_directory }}/.weechat" + recurse: true + owner: "root" + changed_when: ssh_key_pair.changed + when: not weechat__custom_private_repo | bool + +- name: Clone or update private git repository + become: true + when: not weechat__custom_private_repo | bool block: - - name: try to download/update git repo + - name: Try to download/update git repo ansible.builtin.git: repo: "{{ weechat__custom_private_repo }}" dest: "{{ weechat__home_directory }}/.weechat" - version: "{{ weechat__custom_config.version | default ('main') }}" + version: "{{ weechat__custom_config.version | default('main') }}" accept_hostkey: true update: true ssh_opts: "-i {{ weechat__home_directory }}/.ssh/id_ed25519" rescue: - - name: wait until you fixed remote git issues + - name: Wait until you fixed remote git issues ansible.builtin.pause: prompt: "Please fix the issue with your git repository and try again" - - name: try to download/update git repo again + - name: Try to download/update git repo again ansible.builtin.git: repo: "{{ weechat__custom_private_repo }}" dest: "{{ weechat__home_directory }}/.weechat" - version: "{{ weechat__custom_config.version | default ('main') }}" + 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_private_repo | bool -- name: "change git repo owner to {{ weechat__user }}" +- name: "Change git repo owner to {{ weechat__user }}" become: true ansible.builtin.file: path: "{{ weechat__home_directory }}/.weechat" recurse: true owner: "{{ weechat__user }}" + changed_when: ssh_key_pair.changed when: not weechat__custom_private_repo | bool diff --git a/tasks/configure_plugins.yml b/tasks/configure_plugins.yml index 4d086f8..847ce44 100644 --- a/tasks/configure_plugins.yml +++ b/tasks/configure_plugins.yml @@ -1,5 +1,5 @@ --- -- name: create weechat directory +- name: Create weechat directory become: true ansible.builtin.file: path: "{{ weechat__home_directory }}/.weechat" @@ -7,7 +7,7 @@ owner: "{{ weechat__user }}" mode: "0750" -- name: create weechat plugins directory +- name: Create weechat plugins directory become: true ansible.builtin.file: path: "{{ weechat__home_directory }}/.weechat/{{ item.value }}/autoload" @@ -16,16 +16,16 @@ mode: "0750" with_dict: "{{ weechat_plugin_languages }}" -- name: download weechat plugins +- name: Download weechat plugins ansible.builtin.get_url: 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' with_items: '{{ weechat__plugins }}' -- name: symlinking plugins to autoload +- name: Symlinking plugins to autoload ansible.builtin.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 }}' diff --git a/tasks/install-archlinux.yml b/tasks/install-archlinux.yml index 41a6dbe..f8016b8 100644 --- a/tasks/install-archlinux.yml +++ b/tasks/install-archlinux.yml @@ -1,5 +1,5 @@ --- -- name: install weechat if available +- name: Install weechat if available become: true ansible.builtin.package: name: diff --git a/tasks/install-debian.yml b/tasks/install-debian.yml index 8660eab..4cc6442 100644 --- a/tasks/install-debian.yml +++ b/tasks/install-debian.yml @@ -1,5 +1,5 @@ --- -- name: install apt-transport-https +- name: Install apt-transport-https become: true ansible.builtin.apt: name: apt-transport-https @@ -12,21 +12,21 @@ id: "{{ weechat__gpg_id }}" state: present -- name: add weechat repo +- name: Add weechat repo become: true ansible.builtin.apt_repository: repo: "deb {{ weechat__debian_weechat_repo }}" state: present update_cache: true -- name: add weechat repo-src +- name: Add weechat repo-src become: true ansible.builtin.apt_repository: repo: "deb-src {{ weechat__debian_weechat_repo }}" state: present update_cache: true -- name: install recomended weechat packages +- name: Install recomended weechat packages become: true ansible.builtin.apt: name: diff --git a/tasks/install-redhat.yml b/tasks/install-redhat.yml index 41a6dbe..f8016b8 100644 --- a/tasks/install-redhat.yml +++ b/tasks/install-redhat.yml @@ -1,5 +1,5 @@ --- -- name: install weechat if available +- name: Install weechat if available become: true ansible.builtin.package: name: diff --git a/tasks/main.yml b/tasks/main.yml index 88cdc39..5d661a0 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,20 +1,20 @@ --- -- name: perform optinal versionscheck +- 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" +- name: Install weechat + ansible.builtin.include_tasks: "install-{{ ansible_os_family | lower }}.yml" 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 -- name: install requirements for weechat__plugins +- name: Install requirements for weechat__plugins ansible.builtin.include_tasks: configure_plugins.yml when: weechat__install_plugins | bool -- name: setup weechat__autostart +- name: Setup weechat__autostart ansible.builtin.include_tasks: setup_autostart.yml when: weechat__autostart | bool diff --git a/tasks/setup_autostart.yml b/tasks/setup_autostart.yml index 91dee16..cda0bd2 100644 --- a/tasks/setup_autostart.yml +++ b/tasks/setup_autostart.yml @@ -1,12 +1,12 @@ --- -- name: install tmux to launch weechat +- name: Install tmux to launch weechat become: true ansible.builtin.package: name: tmux state: present when: weechat__install | bool -- name: copy systemd service for weechat +- name: Copy systemd service for weechat become: true ansible.builtin.template: src: templates/weechat.service @@ -14,13 +14,13 @@ owner: root group: root mode: '0644' - notify: systemctl restart weechat.service + notify: Run systemctl restart weechat.service -- name: enable weechat.service +- name: Enable weechat.service become: true ansible.builtin.systemd: enabled: true state: started name: weechat.service daemon_reload: true - notify: systemctl restart weechat.service + notify: Run systemctl restart weechat.service diff --git a/tasks/versioncheck.yml b/tasks/versioncheck.yml index 5128cc8..dd22a1a 100644 --- a/tasks/versioncheck.yml +++ b/tasks/versioncheck.yml @@ -8,37 +8,38 @@ path: '/etc/.ansible-version' state: directory mode: 0755 - when: submodules_versioncheck|bool + when: submodules_versioncheck | bool -- name: check playbook version +- name: Check playbook version become: true ansible.builtin.slurp: src: "/etc/.ansible-version/{{ playbook_version_path }}" register: playbook_version - when: submodules_versioncheck|bool + when: submodules_versioncheck | bool ignore_errors: true failed_when: false - name: Print remote role version ansible.builtin.debug: msg: "Remote role version: {{ playbook_version.content | default('Y3VycmVudGx5IG5vdCBkZXBsb3llZAo=') | b64decode | string }}" - when: submodules_versioncheck|bool + when: submodules_versioncheck | bool - name: Print locale role version ansible.builtin.debug: - msg: "Local role version: '{{ playbook_version_number|string }}'." - when: submodules_versioncheck|bool + msg: "Local role version: '{{ playbook_version_number | string }}'." + when: submodules_versioncheck | bool - name: Check if your version is outdated ansible.builtin.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 + - playbook_version.content|default("Mgo=")|b64decode|int - 1 >= playbook_version_number|int and submodules_versioncheck | bool -- name: write new version to remote disk +- name: Write new version to remote disk become: true ansible.builtin.copy: content: "{{ playbook_version_number }}" dest: "/etc/.ansible-version/{{ playbook_version_path }}" mode: '0644' - when: submodules_versioncheck|bool + when: submodules_versioncheck | bool + tags: skip_ansible_lint_template-instead-of-copy diff --git a/vars/main.yml b/vars/main.yml index 7c63149..63ae78b 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,15 +1,15 @@ --- # weechat plugin languages weechat_plugin_languages: - pl: perl - scm: guile - js: javascript - py: python - rb: ruby - lua: lua + pl: 'perl' + scm: 'guile' + js: 'javascript' + py: 'python' + rb: 'ruby' + lua: 'lua' # version management -playbook_version_number: 4221 # should be over ninethousand +playbook_version_number: 4222 # should be over ninethousand 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"