GithubHelp home page GithubHelp logo

viasite-ansible / ansible-role-zsh Goto Github PK

View Code? Open in Web Editor NEW
328.0 16.0 82.0 185 KB

Setup antigen with oh-my-zsh, powerlevel10k theme, fzf, autosuggestions, syntax-highlighting

Home Page: https://habrahabr.ru/post/323496/

Shell 13.81% Python 4.73% Jinja 81.46%
zsh oh-my-zsh powerlevel9k ansible-role ansible-galaxy zsh-autosuggestions zsh-syntax-highlighting fzf zsh-command-time

ansible-role-zsh's Introduction

Build Status

Tested on Ubuntu 18.04, Ubuntu 20.04, Ubuntu 22.04, macOS 10.12, CentOS 8.

For upgrade from viasite-ansible.zsh 1.x, 2.x to 3.0 see below.

Zero-knowledge install:

If you using Ubuntu or Debian and not familiar with Ansible, you can just execute install.sh on target machine:

curl https://raw.githubusercontent.com/viasite-ansible/ansible-role-zsh/master/install.sh | bash

It will install pip3, ansible and setup zsh for root and current user.

Then configure terminal application.

Includes:

Features

  • customize powerlevel9k theme prompt segments and colors
  • default colors tested with solarized dark and default grey terminal in putty
  • add custom prompt elements from yml
  • custom zsh config with ~/.zshrc.local or /etc/zshrc.local
  • load /etc/profile.d scripts
  • install only plugins that useful for your machine. For example, plugin docker will not install if you have not Docker

1.5 mins demo

1.5 mins demo

Color schemes

colors demo

Midnight Commander Solarized Dark skin

If you using Solarized Dark scheme and mc, you should want to install skin, then set zsh_mc_solarized_skin: yes

Demo install in Vagrant

You can test work of role before install in real machine. Just execute vagrant up, then vagrant ssh for enter in virtual machine.

Note: you cannot install vagrant on VPS like Digital Ocean or in Docker. Use local machine for it. Download and install vagrant for your operating system.

Install for real machine

Zero-knowledge install: see above.

Manual install

  1. Install Ansible. For Ubuntu:
sudo apt update
sudo apt install python3-pip -y
sudo pip3 install ansible
  1. Download role:
ansible-galaxy install viasite-ansible.zsh --force
  1. Write playbook or use playbook.yml:
- hosts: all
  vars:
    zsh_antigen_bundles_extras:
      - nvm
      - joel-porquet/zsh-dircolors-solarized
    zsh_autosuggestions_bind_key: "^U"
  roles:
    - viasite-ansible.zsh
  1. Provision playbook:
ansible-playbook -i "localhost," -c local -K playbook.yml

If you want to provision role for root user on macOS, you should install packages manually:

brew install zsh git wget

It will install zsh environment for ansible remote user. If you want to setup zsh for other users, you should define variable zsh_user:

Via playbook:

- hosts: all
  roles:
    - { role: viasite-ansible.zsh, zsh_user: otheruser }
    - { role: viasite-ansible.zsh, zsh_user: thirduser }

Or via command:

ansible-playbook -i hosts zsh.yml -e zsh_user=otheruser
  1. Install fzf without shell extensions, download binary or brew install fzf for macOS.

Note: I don't use tmux-fzf and don't tested work of it.

Multiuser shared install

If you have 10+ users on host, probably you don't want manage tens of configurations and thousands of files.

In this case you can deploy single zsh config and include it to all users.

It causes some limitations:

  • Users have read only access to zsh config
  • Users cannot disable global enabled bundles
  • Possible bugs such cache write permission denied
  • Possible bugs with oh-my-zsh themes

For install shared configuration you should set zsh_shared: yes. Configuration will install to /usr/share/zsh-config, then you just can include to user config:

Install for all users

Set zsh_source_for_all_users: yes

source /usr/share/zsh-config/.zshrc

You can still provision custom configs for several users.

Configure

You should not edit ~/.zshrc! Add your custom config to ~/.zshrc.local (per user) or /etc/zshrc.local (global). .zshrc.local will never touched by ansible.

Configure terminal application

  1. Download powerline fonts, install font that you prefer. You can see screenshots here.

  2. Set color scheme.

Personaly, I prefer Solarized Dark color sceme, Droid Sans Mono for Powerline in iTerm and DejaVu Sans Mono in Putty.

iTerm

Profiles - Text - Change Font - select font "for Powerline"

Profiles - Colors - Color Presets... - select Solarized Dark

Putty

Settings - Window - Appearance - Font settings

You can download Solarized Dark for Putty.

Gnome Terminal

gnome-terminal have built-in Solarized Dark, note that you should select both background color scheme and palette scheme.

Hotkeys

You can view hotkeys in defaults/main.yml, zsh_hotkeys.

Sample hotkey definitions:

- { hotkey: '^r', action: 'fzf-history' }
# with dependency of bundle
- { hotkey: '`', action: autosuggest-accept, bundle: zsh-users/zsh-autosuggestions }

Useful to set autosuggest-accept to ` hotkey, but it conflicts with Midnight Commander (break Ctrl+O subshell).

You can add your custom hotkeys without replace default hotkeys with zsh_hotkeys_extras variable:

zsh_hotkeys_extras:
  - { hotkey: '^[^[[D', action: backward-word } # alt+left
  - { hotkey: '^[^[[C', action: forward-word } # alt+right
  # Example <Ctrl+.><Ctrl+,> inserts 2nd argument from end of prev. cmd
  - { hotkey: '^[,', action: copy-earlier-word } # ctrl+,

Aliases

You can use aliases for your command with easy deploy. Aliases config mostly same as hotkeys config:

zsh_aliases:
  - { alias: 'dfh', action: 'df -h | grep -v docker' }
# with dependency of bundle and without replace default asiases
- zsh_aliases_extra
  - { alias: 'dfh', action: 'df -h | grep -v docker', bundle: }

Default hotkeys from plugins:

  • - accept autosuggestion
  • Ctrl+Z - move current application to background, press again for return to foreground
  • Ctrl+G - jump to bookmarked directory. Use mark in directory for add to bookmarks
  • Ctrl+R - show command history
  • Ctrl+@ - show all fzf-widgets
  • Ctrl+@,C - fzf-change-dir, press fast!
  • Ctrl+\ - fzf-change-recent-dir
  • Ctrl+@,G - fzf-change-repository
  • Ctrl+@,F - fzf-edit-files
  • Ctrl+@,. - fzf-edit-dotfiles
  • Ctrl+@,S - fzf-exec-ssh (using your ~/.ssh/config)
  • Ctrl+@,G,A - fzf-git-add-file
  • Ctrl+@,G,B - fzf-git-checkout-branch
  • Ctrl+@,G,D - fzf-git-delete-branches

Configure bundles

You can check default bundles in defaults/main.yml. If you like default bundles, but you want to add your bundles, use zsh_antigen_bundles_extras variable (see example playbook above). If you want to remove some default bundles, you should use zsh_antigen_bundles variable.

Format of list matches antigen. All bellow variants valid:

- docker # oh-my-zsh plugin
- zsh-users/zsh-autosuggestions # plugin from github
- zsh-users/[email protected] # plugin from github with fixed version
- ~/projects/zsh/my-plugin --no-local-clone # plugin from local directory

Note that bundles can use conditions for load. There are two types of conditions:

  1. Command conditions. Just add command to bundle:
- { name: docker, command: docker }
- name: docker-compose
  command: docker-compose

Bundles docker and docker-compose will be added to config only if commands exists on target system.

  1. When conditions. You can define any ansible conditions as you define in when in tasks:
# load only for zsh >= 4.3.17
- name: zsh-users/zsh-syntax-highlighting
  when: "{{ zsh_version is version_compare('4.3.17', '>=') }}"
# load only for macOS
- { name: brew, when: "{{ ansible_os_family != 'Darwin' }}" }

Note: you should wrap condition in "{{ }}"

Custom config

You can add any code in variable zsh_custom_before, zsh_custom_after.

  • zsh_custom_before - before include antigen.zsh
  • zsh_custom_after - before include ~/.zshrc.local

Upgrade

viasite-ansible.zsh v3.0 introduces antigen v2.0, it don't have backward compatibility to antigen 1.x.

I don't spent much time for smooth upgrade, therefore you probably should do some manual actions: if powerlevel9k prompt don't loaded after provision role, you should execute antigen reset.

After reopen shell all should be done.

Downgrade to antigen v1

Antigen v2 much faster (up to 2x more faster startup), but if something went wrong, you can downgrade to antigen v1, see note for zsh 4.3 users below.

For users with zsh 4.x

Antigen v2 not work on zsh < 5.0, if you use zsh 4.x, please add to you playbook:

zsh_antigen_version: v1.4.1

Known bugs

su username caused errors

See antigen issue. If both root and su user using antigen, you should use su - username in place of su username.

Or you can use bundled alias suser.

Also, you can try to fix it, add to ~/.zshrc.local:

alias su='su -'

But this alias can break you scripts, that using su.

ansible-role-zsh's People

Contributors

agarthetiger avatar beevee avatar belgotux avatar cultclassik avatar exterrestris avatar higidi avatar popstas avatar quantumfate avatar stefanfluit avatar vvmspace avatar yvalentin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-role-zsh's Issues

unarchive: Failed to find handler

Role fails on the "Download fzf" step, which uses the unarchive module.

TASK [viasite-ansible.zsh : Download fzf] **************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Failed to find handler for "/private/var/folders/c6/qyn82s7d2d7dkhzqsl3p5yg80000gn/T/ansible_PEb4Qn/fzf-0.16.8-linux_amd64.tgz". Make sure the required command to extract the file is installed. Command "/usr/bin/tar" detected as tar type bsd. GNU tar required. Command "/usr/bin/unzip" could not handle archive."}

I have both tar and unzip installed:

$ which tar
/usr/bin/tar
$ ls -hal /usr/bin/tar 
lrwxr-xr-x 1 root wheel 6 Jul 16  2015 /usr/bin/tar -> bsdtar
$  which unzip
/usr/bin/unzip
$ ls -hal /usr/bin/unzip
-rwxr-xr-x 2 root wheel 158K May  1  2015 /usr/bin/unzip

OSX, zsh already installed, default playbook, run with ansible-playbook -i 'localhost,' -c local playbook.yml.

I also doubt that https://github.com/junegunn/fzf-bin/releases/download/0.16.8/fzf-0.16.8-linux_amd64.tgz is the correct option for OSX, so I've opened #17. Running the playbook with --extra-vars "zsh_fzf_os={{ ansible_os_family }}" results in using the darwin release, but doesn't fix the problem.

Any ideas on how to debug this further?

MacOS 10.11.6: sudo ansible-playbook -i "localhost," -c local playbook.yml

ERROR! Syntax Error while loading YAML.


The error appears to have been in '/Users/breezzz/ansible/playbook.yml': line 313, column 24, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


  <!-- blob contrib key: blob_contributors:v21:2a361f0c9bff60597da8d52552ffe290 -->
                       ^ here

exception type: <class 'yaml.scanner.ScannerError'>
exception: mapping values are not allowed in this context
  in "<unicode string>", line 313, column 24

please remove zsh_reload

When opened, it will prompt

The `zsh_reload` plugin is deprecated and will be removed.
Use `omz reload` or `exec zsh` instead.

omz includes this function, so the zsh_reload plugin is not needed

Unsupported paramters for (homebrew) module

FAILED! => {"changed": false, "msg": "Unsupported parameters for (homebrew) module: update_cache Supported parameters include: install_options, name, path, state, update_homebrew, upgrade_all"}

Removing this option from the package module in install.yml fixes the issue:
update_cache: yes

OSX Catalina, Homebrew 2.4.1, Ansible 2.9.10

I would be happy to submit a PR but I am fairly new to Ansible. Would the best approach be adding a brew package module call when os == Darwin, and using the existing package module when os != Darwin?

TASK [viasite-ansible.zsh : Merge bundles lists]

Hey.

After executing ./install.sh on debian stretch for manual install i got the following issue for the TASK [viasite-ansible.zsh : Merge bundles lists]:

fatal: [localhost]: FAILED! => {"msg": "An unhandled exception occurred while templating '[{u'when': u"{{ ansible_os_family != 'Darwin' }}", u'name': u'command-not-found'}, {u'command': u'brew', u'name': u'brew'}, {u'command': u'docker', u'name': u'docker'}, {u'command': u'docker-compose', u'name': u'docker-compose'}, u'fancy-ctrl-z', u'git-extras', u'gnu-utils', {u'command': u'http', u'name': u'httpie'}, {u'command': u'go', u'name': u'go'}, {u'command': u'gulp', u'name': u'gulp'}, {u'command': u'pip', u'name': u'pip'}, {u'command': u'rake', u'name': u'rake'}, {u'command': u'symfony', u'name': u'symfony2'}, {u'command': u'systemctl', u'name': u'systemd'}, u'python', {u'command': u'tmux', u'name': u'tmux'}, {u'command': u'vagrant', u'name': u'vagrant'}, {u'command': u'drall', u'name': u'viasite/drall'}, {u'command': u'drs', u'name': u'viasite/drupal-scripts'}, {u'command': u'dbdump', u'name': u'viasite/server-scripts'}, {u'command': u'ansible-deploy', u'name': u'viasite-ansible/zsh-ansible-server'}, u'zsh_reload', {u'when': u"{{ zsh_version | default(false) | version_compare('5.0', '>=') }}", u'name': u'zsh-users/zsh-autosuggestions'}, u'popstas/zsh-command-time', {u'when': u'{{ zsh_update_interval > 0 }}', u'name': u'unixorn/autoupdate-antigen.zshplugin'}, u'urbainvaes/fzf-marks', u'{{ fzf_widgets }}', {u'when': u"{{ zsh_version | default(false) | version_compare('4.3.17', '>=') }}", u'name': u'zdharma/[email protected]'}]'. Error was a <class 'ansible.errors.AnsibleError'>, original message: template error while templating string: no filter named 'version_compare'. String: {{ zsh_version | default(false) | version_compare('5.0', '>=') }}"}

Any ideas to fix it?

autosuggestions: Wishing to delete the Ctrl+U binding

Thank you for your work, the results are fantastic. When I get a new machine I just run curl

https://raw.githubusercontent.com/viasite-ansible/ansible-role-zsh/master/install.sh | bash

But the default setting I think has a drawback

bindkey '^U' autosuggest-accept

This is done by default with Ctrl+E, and the binding disables the original Ctrl+U.

It is proposed that it be deleted from the project

TASK [viasite-ansible.zsh : Install zsh, git, wget, fd-find] failed on Mac 13.6.4

I am on a

Mac Intel on Ventura 13.6.4

My playbook looks like:

---
- name: Configure host
  hosts: all

  roles:
    - role: viasite-ansible.zsh
      tags: ['zsh']

If I run
ansible-playbook main.yml -K --tags="zsh"

I get the following error message:

TASK [viasite-ansible.zsh : Install zsh, git, wget, fd-find] ***********************************************************************************************************************
fatal: [127.0.0.1]: FAILED! => {"changed": false, "msg": "Error: Running Homebrew as root is extremely dangerous and no longer supported.\nAs Homebrew does not drop privileges on installation you would be giving all\nbuild scripts full access to your system."}

If I change in install.yml to become: no in line 18, the next error pops up.

TASK [viasite-ansible.zsh : Install zsh, git, wget, fd-find] ************************************************************************************************************************
fatal: [127.0.0.1]: FAILED! => {"changed": false, "msg": "Error: No available formula with the name \"fd-find\". Did you mean ffind?"}

fd-find is not available via brew on Mac.

If I change the line 15 in install.yml to - fd everthing works fine. As fd is available via brew.

Error message when fzf-widgets disabled

If I remove fzf-widgets bundle in zsh_antigen_bundles , will get error message like below:

/home/vagrant/.zshrc:49: FZF_WIDGETS_OPTS: assignment to invalid subscript range

Upgrade to antigen v2

Antigen updated to v2, see CHANGELOG.md.

It changed bundles path and maybe have something other incompatibilities.

Need to prepare role for upgrade to antigen v2.

How can I disable a bundle?

I want to disable the the auto suggestion bundle but from what I have found I appear to have to edit the .zshrc which says to not edit it and to use the .zshrc.local. I just wanted to check if there was a way I am not aware of or if I should make a PR to add functionality to be able to choose bundles you dont want?

command conditions don't work on centos

zsh_antigen_bundles:
  - { name: brew, command: brew }

command conditionals for bundles introduced in #2, broken.

Expected that bundle will don't loading if command brew is absent, but it loads.

ALMA 9.3 fdfind: command not found...

When running the ansible role on ALMA 9.3 I encounter warnings:

zsh: fdfind: command not found...

fd-find is installed in /usr/bin/fd and not /usr/bin/fdfind

Removing this command from templates/zshrc.js2
LINE 45 alias fd=fdfind # for correct working of sorenson-axial/fzf-widgets
Should fix the problem.

Maybe can be fixed using something similar to:
ansible_os_family == 'Debian'

PS: Sorry I am new to issues and contributing to public repos, Should I open an pull request?

extend list of plugins

How to extend list of plugins?
If I add them in .zshrc.local it doesn't affect list of plugins

Installer for user fails: Permission denied

While provision role for root ansible creates directory in user directory with owner root.
Then provision from user fails:

TASK [viasite-ansible.zsh : Clone antigen master] ******************************
fatal: [localhost]: FAILED! => {"changed": false, "cmd": "/usr/bin/git clone --origin origin https://github.com/zsh-users/antigen.git /home/popstas/.antigen/antigen", "failed": true, "msg": "fatal: could not create work tree dir '/home/popstas/.antigen/antigen': Permission denied", "rc": 128, "stderr": "fatal: could not create work tree dir '/home/popstas/.antigen/antigen': Permission denied\n", "stderr_lines": ["fatal: could not create work tree dir '/home/popstas/.antigen/antigen': Permission denied"], "stdout": "", "stdout_lines": []}
        to retry, use: --limit @/tmp/zsh.retry

create direcoty ~test1/.antigen

Hello.
When running ansible-playbook OhMyZSH.yml --limit=MyHome

---
- hosts: all
  vars:
    # your extra bundles here
    zsh_antigen_bundles_extras: []
    # your variables here
    # zsh_autosuggestions_bind_key: "^U"
  roles:
    - { role: viasite-ansible.zsh, zsh_user: test1 }
    #    - viasite-ansible.zsh

I'm getting an error.

PLAY [all] ******************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ******************************************************************************************************************************************************************************************
ok: [myunit1-minipc-home]
ok: [u1-g6]

TASK [viasite-ansible.zsh : include_tasks] **********************************************************************************************************************************************************************
included: /home/fly/MyAnsible/roles/viasite-ansible.zsh/tasks/install.yml for u1-g6, myunit1-minipc-home

TASK [viasite-ansible.zsh : Update package cache] ***************************************************************************************************************************************************************
changed: [u1-g6]
changed: [myunit1-minipc-home]

TASK [viasite-ansible.zsh : Install zsh, git, wget, fd-find] ****************************************************************************************************************************************************
ok: [u1-g6]
ok: [myunit1-minipc-home]

TASK [viasite-ansible.zsh : check if ~test1/.antigen exist] *****************************************************************************************************************************************************
ok: [u1-g6]
ok: [myunit1-minipc-home]

TASK [viasite-ansible.zsh : create direcoty ~test1/.antigen] ****************************************************************************************************************************************************
fatal: [myunit1-minipc-home]: FAILED! => {"msg": "Failed to set permissions on the temporary files Ansible needs to create when becoming an unprivileged user (rc: 1, err: chmod: invalid mode: ‘A+user:test1:rx:allow’\nTry 'chmod --help' for more information.\n}). For information on working around this, see https://docs.ansible.com/ansible-core/2.15/playbook_guide/playbooks_privilege_escalation.html#risks-of-becoming-an-unprivileged-user#risks-of-becoming-an-unprivileged-user"}
fatal: [u1-g6]: FAILED! => {"msg": "Failed to set permissions on the temporary files Ansible needs to create when becoming an unprivileged user (rc: 1, err: chmod: invalid mode: 'A+user:test1:rx:allow'\nTry 'chmod --help' for more information.\n}). For information on working around this, see https://docs.ansible.com/ansible-core/2.15/playbook_guide/playbooks_privilege_escalation.html#risks-of-becoming-an-unprivileged-user#risks-of-becoming-an-unprivileged-user"}

PLAY RECAP ******************************************************************************************************************************************************************************************************
myunit1-minipc-home        : ok=5    changed=1    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0
u1-g6                      : ok=5    changed=1    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

Please pay attention to create direcoty ~test1/.antigen and check if ~test1/.antigen exist]. I assume that the role does not form the path correctly.

Ошибка возникает на:
Ubuntu Desktop 22.04.1
and
Ubuntu Server 22.04.3

'antigen bundle [' in ~/.zshrc

Just deployed this playbook on a new machine. Got this in my ~/.zshrc:

...
source "$HOME/.antigen/antigen/antigen.zsh"

antigen use oh-my-zsh


antigen bundle [
antigen bundle {
antigen bundle '
antigen bundle n
antigen bundle a
antigen bundle m
antigen bundle e
antigen bundle '
antigen bundle :
antigen bundle
antigen bundle '
antigen bundle c
antigen bundle o
antigen bundle m
antigen bundle m
antigen bundle a
antigen bundle n
antigen bundle d
antigen bundle -
antigen bundle n
antigen bundle o
antigen bundle t
antigen bundle -
antigen bundle f
antigen bundle o
antigen bundle u
antigen bundle n
antigen bundle d
antigen bundle '
...

Looks like a big data structure is witten one letter at a line.

$ cat ~/.zshrc | grep 'antigen bundle' | sed 's/antigen bundle //g' | awk '{printf $0}'
[{'name': 'command-not-found', 'when': False}, {'name': 'brew', 'command': 'brew'}, {'name': 'docker', 'command': 'docker'}, {'name': 'docker-compose', 'command': 'docker-compose'}, 'fancy-ctrl-z', 'git-extras', 'gnu-utils', {'name': 'httpie', 'command': 'http'}, {'name': 'golang', 'command': 'go'}, {'name': 'gulp', 'command': 'gulp'}, {'name': 'helm', 'command': 'helm'}, {'name': 'kubectl', 'command': 'kubectl'}, {'name': 'pip', 'command': 'pip'}, {'name': 'rake', 'command': 'rake'}, {'name': 'symfony2', 'command': 'symfony'}, {'name': 'systemd', 'command': 'systemctl'}, 'python', {'name': 'tmux', 'command': 'tmux'}, {'name': 'vagrant', 'command': 'vagrant'}, {'name': 'viasite/server-scripts', 'command': 'dbdump'}, {'name': 'zsh-users/zsh-autosuggestions', 'when': True}, 'popstas/zsh-command-time', {'name': 'unixorn/autoupdate-antigen.zshplugin', 'when': True}, 'urbainvaes/fzf-marks', 'ytet5uy4/fzf-widgets', {'name': 'zdharma-continuum/fast-syntax-highlighting', 'when': True}] + ['nvm']% 

$ ansible --version                                        
ansible [core 2.13.1]
  config file = None
  configured module search path = ['/Users/nick/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/homebrew/Cellar/ansible/6.1.0/libexec/lib/python3.10/site-packages/ansible
  ansible collection location = /Users/nick/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/homebrew/bin/ansible
  python version = 3.10.5 (main, Jun 23 2022, 17:07:30) [Clang 13.0.0 (clang-1300.0.29.30)]
  jinja version = 3.1.2
  libyaml = True


$  ansible-galaxy list
# /Users/nick/.ansible/roles
- viasite-ansible.zsh, v3.5.2

Version comparison: '<' not supported between instances of 'str' and 'int'

With latest updates of Vagrant, I get this error regarding this line on tasks/configure.yml:

TASK [zsh : Check commands exists] *********************************************
[DEPRECATION WARNING]: Using tests as filters is deprecated. Instead of using
`result|version` use `result is version`. This feature will be removed in
version 2.9. Deprecation warnings can be disabled by setting
deprecation_warnings=False in ansible.cfg.
fatal: [default]: FAILED! => {"msg": "An unhandled exception occurred while templating 
'[{'name': 'command-not-found', 'when': \"{{ ansible_os_family != 'Darwin' }}\"}, {'name': 'brew', 'command': 'brew'}, 
{'name': 'docker', 'command': 'docker'}, {'name': 'docker-compose', 'command': 'docker-compose'}, 'fancy-ctrl-z', 
'git-extras', 'gnu-utils', {'name': 'httpie', 'command': 'http'}, {'name': 'go', 'command': 'go'}, 
{'name': 'gulp', 'command': 'gulp'}, {'name': 'pip', 'command': 'pip'}, {'name': 'rake', 'command': 'rake'}, 
{'name': 'symfony2', 'command': 'symfony'}, {'name': 'systemd', 'command': 'systemctl'}, 'python', {'name': 'tmux', 'command': 'tmux'}, 
{'name': 'vagrant', 'command': 'vagrant'}, {'name': 'viasite/drall', 'command': 'drall'}, {'name': 'viasite/drupal-scripts', 'command': 'drs'}, 
{'name': 'viasite/server-scripts', 'command': 'dbdump'}, {'name': 'viasite-ansible/zsh-ansible-server', 'command': 'ansible-deploy'}, 'zsh_reload', 
{'name': 'zsh-users/zsh-autosuggestions', 'when': \"{{ zsh_version | default(false) | version('5.0', '>=') }}\"}, 'popstas/zsh-command-time', 
{'name': 'unixorn/autoupdate-antigen.zshplugin', 'when': '{{ zsh_update_interval > 0 }}'}, 'urbainvaes/fzf-marks', '{{ fzf_widgets }}', 
{'name': 'zdharma/[email protected]', 'when': \"{{ zsh_version | default(false) | version('4.3.17', '>=') }}\"}]'. Error was a 
<class 'ansible.errors.AnsibleFilterError'>, 
original message: Version comparison: '<' not supported between instances of 'str' and 'int'"}
...ignoring

TASK [viasite-ansible.zsh : Download fzf to ~root/bin] fails on arm architecture

TASK [viasite-ansible.zsh : Download fzf to ~root/bin] **********************************************************************************
task path: /home/leonch/.ansible/roles/viasite-ansible.zsh/tasks/install.yml:66
changed: [quantumhome] => {"changed": true, "dest": "/root/bin", "extract_results": {"cmd": ["/usr/bin/tar", "--extract", "-C", "/root/bin", "-z", "-f", "/home/sao/.ansible/tmp/ansible-tmp-1661069264.8627656-420241-35450988546255/fzf-0.28.0-linux_amd64.tar_m41ff9w.gz"], "err": "", "out": "", "rc": 0}, "gid": 0, "group": "root", "handler": "TgzArchive", "mode": "0775", "owner": "root", "size": 4096, "src": "/home/sao/.ansible/tmp/ansible-tmp-1661069264.8627656-420241-35450988546255/fzf-0.28.0-linux_amd64.tar_m41ff9w.gz", "state": "directory", "uid": 0}
fatal: [raspberrypi]: FAILED! => {"changed": false, "msg": "Invalid archive '/home/pi/.ansible/tmp/ansible-tmp-1661069264.8863418-420242-47481378950163/fzf-0.28.0-linux_386.tarlg31dwr7.gz', the file is 0 bytes"}

Offending line: in vars/main.yml

zsh_fzf_arch: "{% if '64' in ansible_architecture %}amd64{% else %}386{% endif %}"

No zprofile?

I have a situation where I'm also installing Ruby using geerlingguy's role. This places a shell script in /etc/profile.d/ called rubygems.sh. (There are several other *.sh files there, btw.)

Because zsh does not source /etc/profile (to the best of my knowledge), none of these scripts ever run. However, isn't zsh supposed to install /etc/zprofile? If so, this role does not do so. Thus, no scripts in /etc/profile.d/ are ever sourced and, therefore, Ruby and some gems I install using geerlingguy's role are not accessible.

Am I wrong about any of this? Or what sort of fix needs to happen here?

Replace sudo with become and --ask-become-pass

This roles uses become to let ansible operate as a privileged user. This is the right and preferred way. But instead of asking for become password, the README recommends to run ansible with sudo:

sudo ansible-playbook -i "localhost," -c local playbook.yml

This doesn't seem to be the right or required practice. For me it resulted in files in my ~/ owned by root a couple of times. Instead, we can tell ansible to ask for password with --ask-become-pass or -K:

ansible-playbook -i "localhost," -c local -K playbook.yml

Also, it seems that ansible-galaxy does not need sudo either:

sudo ansible-galaxy install viasite-ansible.zsh

If you agree, I will throw a pull-request myself.

How to deal with autoload and oh-my-zsh plugins?

Is it possible to have a program installed with this role that is only installed via autoload?

For example, I wish to have zmv installed, along with all the other extras (powerlevel10k, zsh-autosuggestions, etc.). However, I don't think I can simply add it to the zsh_antigen_bundles_extras variable because it's not considered a bundle. According to my research, it can only be installed by running autoload zmv on the shell. The same goes for another program called zcalc.

The same goes for enabling built-in oh-my-zsh plugins. I'd like to enable npm and sudo, but I don't know how to do it with this role, short of manually editing the .zshrc.local file after running it.

Is there a way to install these things with this role instead?

when conditions don't work for bundles

zsh_antigen_bundles:
  - { name: command-not-found, when: ansible_os_family != "Darwin" }

when conditionals for bundles introduced in #2 broken.

Expected that bundle will don't loading on macOS, but it loads.

Add zsh_antigen_bundles_extras

Variable zsh_antigen_bundles very complex. Need for other variable for define user bundles without copy-paste whole zsh_antigen_bundles_extras.

Alias 'ag' of plugin 'debian' conflicts with the_silver_searcher

the_silver_searcher implemented as ag command.

Plugin debian overrides ag with alias.

I checked that I actually don't use anything alias from plugin and decided to remove it from default bundles.

If you used this plugin and found this issue, please notify me.

I think that I don't affected anybody.

You can still add debian plugin to zsh_antigen_bundles_extras in your playbook:

zsh_antigen_bundles_extras:
  - { name: debian, when: ansible_os_family == "Debian" }

Fails when running in check mode

When running in check mode (--check) the playbook fails on several tasks (I think the ones that require data from registered variables?). I believe best practice is just to ignore or not run those tasks when running check mode.

insecure directories and files

~  sudo -s  ✘  23:16:19
zsh compinit: insecure directories and files, run compaudit for list.
Ignore insecure directories and files and continue [y] or abort compinit [n]?

~  compaudit  ✘  23:16:10
There are insecure directories and files:
/home/jss/.antigen/bundles/ytet5uy4/fzf-widgets/autoload/libexec
/home/jss/.antigen/bundles/ytet5uy4/fzf-widgets/autoload/widgets
/home/jss/.antigen/bundles/robbyrussell/oh-my-zsh/lib
/home/jss/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/command-not-found
/home/jss/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/fancy-ctrl-z
/home/jss/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/git-extras
/home/jss/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/gnu-utils
/home/jss/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/rake
/home/jss/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/systemd
/home/jss/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/python
/home/jss/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/vagrant
/home/jss/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/zsh_reload
/home/jss/.antigen/bundles/zsh-users/zsh-autosuggestions
/home/jss/.antigen/bundles/popstas/zsh-command-time
/home/jss/.antigen/bundles/unixorn/autoupdate-antigen.zshplugin
/home/jss/.antigen/bundles/urbainvaes/fzf-marks
/home/jss/.antigen/bundles/ytet5uy4/fzf-widgets
/home/jss/.antigen/bundles/zdharma/fast-syntax-highlighting
/home/jss/.antigen/bundles/ytet5uy4/fzf-widgets/autoload
/home/jss/.antigen/bundles/ytet5uy4/fzf-widgets/autoload
/home/jss/.antigen/bundles/robbyrussell/oh-my-zsh
/home/jss/.antigen/bundles/robbyrussell/oh-my-zsh/plugins
/home/jss/.antigen/bundles/robbyrussell/oh-my-zsh/plugins
/home/jss/.antigen/bundles/robbyrussell/oh-my-zsh/plugins
/home/jss/.antigen/bundles/robbyrussell/oh-my-zsh/plugins
/home/jss/.antigen/bundles/robbyrussell/oh-my-zsh/plugins
/home/jss/.antigen/bundles/robbyrussell/oh-my-zsh/plugins
/home/jss/.antigen/bundles/robbyrussell/oh-my-zsh/plugins
/home/jss/.antigen/bundles/robbyrussell/oh-my-zsh/plugins
/home/jss/.antigen/bundles/robbyrussell/oh-my-zsh/plugins
/home/jss/.antigen/bundles/zsh-users
/home/jss/.antigen/bundles/popstas
/home/jss/.antigen/bundles/unixorn
/home/jss/.antigen/bundles/urbainvaes
/home/jss/.antigen/bundles/ytet5uy4
/home/jss/.antigen/bundles/zdharma
/home/jss/.antigen/bundles/ytet5uy4/fzf-widgets/autoload/libexec/__fzf::widget::check
/home/jss/.antigen/bundles/ytet5uy4/fzf-widgets/autoload/libexec/__fzf::widget::clear
/home/jss/.antigen/bundles/ytet5uy4/fzf-widgets/autoload/libexec/__fzf::widget::exec
/home/jss/.antigen/bundles/ytet5uy4/fzf-widgets/autoload/libexec/__fzf::widget::filter
/home/jss/.antigen/bundles/ytet5uy4/fzf-widgets/autoload/libexec/__fzf::widget::init
/home/jss/.antigen/bundles/ytet5uy4/fzf-widgets/autoload/libexec/__fzf::widget::insert
/home/jss/.antigen/bundles/ytet5uy4/fzf-widgets/autoload/libexec/__fzf::widget::print
/home/jss/.antigen/bundles/ytet5uy4/fzf-widgets/autoload/libexec/__fzf::widget::replace
/home/jss/.antigen/bundles/ytet5uy4/fzf-widgets/autoload/libexec/__fzf::widget::select
/home/jss/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/python/_python
/home/jss/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/vagrant/_vagrant

~  chmod -R 700 .antigen  23:21:08

~  chown -R jss:jss .antigen  23:21:16

~  ls -l /home/jss/.antigen/bundles  23:21:20
итого 32
drwx------ 3 jss jss 4096 фев 4 01:36 bhilburn
drwx------ 3 jss jss 4096 фев 4 01:36 popstas
drwx------ 3 jss jss 4096 фев 4 01:36 robbyrussell
drwx------ 3 jss jss 4096 фев 4 01:36 unixorn
drwx------ 3 jss jss 4096 фев 4 01:36 urbainvaes
drwx------ 3 jss jss 4096 фев 4 01:36 ytet5uy4
drwx------ 3 jss jss 4096 фев 4 01:36 zdharma
drwx------ 3 jss jss 4096 фев 4 01:36 zsh-users

~  sudo -s  23:21:23
zsh compinit: insecure directories and files, run compaudit for list.
Ignore insecure directories and files and continue [y] or abort compinit [n]?

Windows line-endings?

I ran this role a few days ago and now, each time I start up a shell instance, I receive a bunch of error messages, all of which show ^M at the end of their lines:

Seems zsh-users/zsh-autosuggestions is already installed!
/home/sturm/.antigen/bundles/robbyrussell/oh-my-zsh/lib/cli.zsh:2: command not found: ^M
/home/sturm/.antigen/bundles/robbyrussell/oh-my-zsh/lib/cli.zsh:34: parse error near `elif'
/home/sturm/.antigen/bundles/robbyrussell/oh-my-zsh/lib/functions.zsh:3: parse error near `|'
/home/sturm/.antigen/bundles/robbyrussell/oh-my-zsh/lib/git.zsh:31: parse error near `in^M'
/home/sturm/.antigen/bundles/robbyrussell/oh-my-zsh/lib/history.zsh:4: not an identifier: list^M
/home/sturm/.antigen/bundles/robbyrussell/oh-my-zsh/lib/misc.zsh:21: command not found: env_default
/home/sturm/.antigen/bundles/robbyrussell/oh-my-zsh/lib/misc.zsh:22: command not found: env_default
/home/sturm/.antigen/bundles/robbyrussell/oh-my-zsh/lib/nvm.zsh:7: parse error near `\n'
/home/sturm/.antigen/bundles/robbyrussell/oh-my-zsh/lib/termsupport.zsh:setopt:11: no such option: prompt_subst^M
/home/sturm/.antigen/bundles/robbyrussell/oh-my-zsh/lib/termsupport.zsh:12: command not found: ^M
/home/sturm/.antigen/bundles/robbyrussell/oh-my-zsh/lib/termsupport.zsh:14: command not found: ^M
/home/sturm/.antigen/bundles/robbyrussell/oh-my-zsh/lib/termsupport.zsh:18: command not found: ^M
/home/sturm/.antigen/bundles/robbyrussell/oh-my-zsh/lib/termsupport.zsh:19: parse error near `in^M'
/home/sturm/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/kubectl/kubectl.plugin.zsh:181: parse error near `\n'
/home/sturm/.antigen/bundles/urbainvaes/fzf-marks/fzf-marks.plugin.zsh:38: parse error near `elif'
/home/sturm/.antigen/bundles/joel-porquet/zsh-dircolors-solarized/zsh-dircolors-solarized.plugin.zsh:source:2: no such file or directory: /home/sturm/.antigen/bundles/joel-porquet/zsh-dircolors-solarized/zsh-dircolors-solarized.zsh^M
/home/sturm/.antigen/bundles/zsh-users/zsh-syntax-highlighting/highlighters/main/main-highlighter.zsh:187: parse error near `elif'
zsh-syntax-highlighting: 'main' highlighter should define both required functions '_zsh_highlight_highlighter_main_paint' and '_zsh_highlight_highlighter_main_predicate' in '/home/sturm/.antigen/bundles/zsh-users/zsh-syntax-highlighting/highlighters/main/main-highlighter.zsh'.
/home/sturm/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/colored-man-pages/colored-man-pages.plugin.zsh:typeset:6: not valid in this context: less_termcap^M

I've also documented this issue on Antigen's repo, but I have a feeling it has something to do with this role.

For info, I'm running this on an Ubuntu-20.04 WSL2 instance.

Can anyone please help me to understand what's going on?

parameterized template file

zshrc.j2 is hard coded in tasks/configure.yml.

But I want to use my custom template to use as below for blockinfile.

# BEGIN MY CUSTOM FASD SETTING
# END MY CUSTOM FASD SETTING

Could I create a PR?

ansible 2.13.1 ''str object'' has no attribute ''hotkey'''

The role is throwing an error when running with Ansible 2.13.1:

fatal: [machine-06]: FAILED! => changed=false 
  msg: 'AnsibleUndefinedVariable: ''str object'' has no attribute ''hotkey'''

When i downgrade to 2.12.3 then it works again.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.