gantsign / ansible-role-oh-my-zsh Goto Github PK
View Code? Open in Web Editor NEWAnsible role for installing and configuring oh-my-zsh
Home Page: https://galaxy.ansible.com/gantsign/oh-my-zsh
License: MIT License
Ansible role for installing and configuring oh-my-zsh
Home Page: https://galaxy.ansible.com/gantsign/oh-my-zsh
License: MIT License
Hi 👋
I'm trying to run this role against a Ubuntu 22.04.4 LTS instance:
roles:
- role: gantsign.oh-my-zsh
become: true
tags:
- shell_setup
users:
- username: nwon
oh_my_zsh:
theme: maran
plugins:
- git
Getting this error:
TASK [gantsign.oh-my-zsh : write .zshrc for users] ****************************************************************************
fatal: [resolvio-testing-new]: 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:nwon:rx:allow’\nTry 'chmod --help' for more information.\n}). For information on working around this, see https://docs.ansible.com/ansible-core/2.16/playbook_guide/playbooks_privilege_escalation.html#risks-of-becoming-an-unprivileged-user"}
… where I think the interesting bit is:
chmod: invalid mode: ‘A+user:nwon:rx:allow’
FWIW, chmod --version
yields chmod (GNU coreutils) 8.32
. But the syntax looks pretty odd, so I don't think it's a version problem.
Do you have any idea what's going on here? Thanks a lot for any insights 🙏
Hi,
The users
variable name is too generic as it can be used by different other roles.
Would you mind set it to a more specific name such as oh_my_zsh_users
(I took it from others of your variables).
If you need me to do a PR, just let me know.
Regards,
Rudy
It's likely the role already works on OpenSUSE 42.2 but it should be added to the test matrix and added to the Ansible metadata.
Hi its could be interesting to prefix the users variables beacuase its way too generic ^^
It's likely the role already works on CentOS 7 but they should be added to the test matrix and added to the Ansible metadata.
Hi,
I've been using your role and have had no issue, but I have a possible upgrade that could be made :
A boolean could be added to skip the default .zshrc file creation on install. Currently, when i rerun the playbook I have that uses this role this task is always marked as changed because I put my own custom .zshrc file later, and it would be nice if this small change could be added.
Kind regards,
David
hello, I just want to install oh-my-zsh
for multiple users, so how can I do this?
Here is my Ansible playbook, but it throws an error (item not found)
- name: setup ohmyzsh for users
hosts: all
vars:
userlist:
- username: "viktor"
password: "viktor123"
become: yes
roles:
- role: gantsign.oh-my-zsh
users:
- username: "{{ item.username }}"
oh_my_zsh:
theme: gnzh
plugins:
- git
- zsh-syntax-highlighting
- zsh-autosuggestions
- docker
loop: "{{ userlist }}"
Specify custom themes in a 'themes' list and custom plugins in a 'plugins' list, each item having a 'name' and 'source' identifying its Git repo. Install the custom theme if a user has it named as their 'theme'. Install custom plugins if they are listed by name in a user's plugins list. I will have a PR ready shortly to address these features.
Thank you for this role, really nice and easy to use. I did try the antigen one but I'm not familiar with it just yet and it failed on macOS which is what I'm targetting mainly.
So I would like to add custom content to the .zshrc
file but at the moment the jinja file doesn't support adding custom snippets. I can of course override in subsequent plays / roles but it doesn't feel very ansible like to do that.
I've got two options in my head and which would be best based on your experience:
# oh_my_zsh_zshrc_custom: ""
oh_my_zsh_zshrc_custom: |
<insert script content here>
Eg. append at end of current template:
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
{{ oh_my_zsh_zshrc_custom }}
# oh_my_zsh_zshrc_custom_template: ""
oh_my_zsh_zshrc_custom_template: "{{ playbook_dir}}/templates/my_zshrc.j2"
Happy to do a PR if you think either of those options would be useful?
[EDIT] - Just seen this: #89
Also I realised that adding scripts to the ~/.oh-my-zsh/custom directory get included by default.
I was able to configure another role to output it's zsh config to a file there and it works.
Not sure if this is an expected behaviour, but after changing the gefault theme to "gnzh" and running the role/playbook again I can't see a change on my machines .zshrc...
Expected behaviour would be for it to be like this:
ZSH_THEME="XYZ"
changes to whatever I set in
- role: gantsign.oh-my-zsh
users:
- username: '{{remoteuser}}'
oh_my_zsh:
theme: gnzh
plugins:
- git
sadly same is true if I add more plugins to the above shown array...
It's likely the role already works on Debian Wheezy & Jessie but they should be added to the test matrix and added to the Ansible metadata.
Hello what do you think about adding a way to install custom plugins ?
Generally it means:
plugins
listIt's likely the role already works on Fedora 25 but it should be added to the test matrix and added to the Ansible metadata.
It would be nice if users could override the .zshrc
template. You can accomplish this by making the contents of src
a variable. See this PR as an example: https://github.com/geerlingguy/ansible-role-gitlab/pull/89/files
I have been using your role for quite a while, thanks!
I've ran into some troubles with the latest version. At first I thought it was Ansible 2.7 that caused it, but that is unrelated (I updated but Ansible and the role at the same time). In the end I downgrade to a previous version of the role and it worked fine again.
`TASK [gantsign.oh-my-zsh : clone oh-my-zsh for users] ************************************************************************************************************************************************************
ok: [x.lan] => (item={u'username': u'user', u'oh_my_zsh': {u'theme': u'robbyrussell', u'plugins': [u'git', u'docker', u'cpv', u'copydir', u'copyfile', u'zsh-syntax-highlighting']}})
[WARNING]: Module remote_tmp /home/docker/.ansible/tmp did not exist and was created with a mode of 0700, this may cause issues when running as another user. To avoid this, create the remote_tmp dir with the
correct permissions manually`
And later on:
`TASK [gantsign.oh-my-zsh : write .zshrc for users] ***************************************************************************************************************************************************************
changed: [x.lan] => (item={u'username': u'user', u'oh_my_zsh': {u'theme': u'robbyrussell', u'plugins': [u'git', u'docker', u'cpv', u'copydir', u'copyfile', u'zsh-syntax-highlighting']}})
fatal: [x.lan]: FAILED! => {"msg": "Failed to set permissions on the temporary files Ansible needs to create when becoming an unprivileged user (rc: 1, err: chown: changing ownership of '/var/tmp/ansible-tmp-1538996917.56-214497945895580/': Operation not permitted\nchown: changing ownership of '/var/tmp/ansible-tmp-1538996917.56-214497945895580/source': Operation not permitted\n}). For information on working around this, see https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user"}`
I saw Dependabot got added today and has already started to attempt pull requests.
Unfortunately, those pull requests get stuck with the license/cla
check. The reason for this is that the Dependabot is not yet whitelisted in cla-assistant.
An explantion on whitelisting bots is provided here: cla-assistant/cla-assistant#173 (comment)
The oh-my-zsh prompt uses symbols to show whether the previous command completed successfully. If the console is running in ISO-8859-1 (or any other non-UTF-8 charmap the symbol appears as a series of garbled characters.
When installing the role on OSX, the following error is received:
TASK [gantsign.oh-my-zsh : install dependencies] ****************************************************************************************************************************************************************************************
failed: [localhost] (item=git) => {"ansible_loop_var": "item", "changed": false, "item": "git", "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."}
Example configuration:
- role: gantsign.oh-my-zsh
users:
- username: "{{ user_name }}"
plugins:
- git
- kube-ps1
- vscode
Simple role with username only installs zsh, oh-my-zsh but user to be able to 'use' oh-my-zsh must type zsh in the terminal anyway In fact zsh is being set as default shell as expected but still themes and other stuff not loading automatically.
Os: Ubuntu 20 Focal LTS
Hello!
Thank you for your work, I just have one question: I noticed that on the lines 30 and 31 of the templates/zshrc.j2
does not match with the current .zshrc file on the ohmyzsh repo, so I was wondering if it's ok to create a PR that enables the updates? Or if its better just to leave it as it's.
ansible-role-oh-my-zsh/templates/zshrc.j2
Lines 30 to 31 in d4e4460
Kindest regards
Hi,
I usually perform all administrative tasks on my servers with a user different from "root". Unfortunately, in such case, it is impossible to perform some tasks as another user using Ansible privilege escalation.
The task write .zshrc for users
will fail if it is executed for any user when connected as unprivilegied user:
TASK [gantsign.oh-my-zsh : write .zshrc for users] **************************************************
fatal: [ec2-**-***-***-***.eu-west-3.compute.amazonaws.com]: FAILED! => {}
MSG:
Failed to set permissions on the temporary files Ansible needs to create when becoming an unprivileged user (rc: 1, err: chown: changing ownership of '/var/tmp/ansible-tmp-1569230087.9570866-96215917740751/': Operation not permitted
chown: changing ownership of '/var/tmp/ansible-tmp-1569230087.9570866-96215917740751/source': Operation not permitted
}). For information on working around this, see https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user
with playbook
- hosts: all
remote_user: my_admin_user
vars:
users:
- username: dummy
oh_my_zsh:
theme: sporty_256
plugins:
- git
- themes
roles:
- gantsign.oh-my-zsh
The error came from the task:
- name: write .zshrc for users
become: yes
become_user: '{{ item.username }}'
template:
src: zshrc.j2
dest: '~{{ item.username }}/.zshrc'
backup: yes
mode: 'u=rw,go=r'
with_items: '{{ users }}'
In Ansible docs, the suggested workarounds are:
I have enabled pipelining (1) in ansible.cfg, to ensure most of the tasks works well (cloning the repository in ~dummy/.oh-my-zsh
can be done by user my_admin_user
). But since the last task use template
module to write .zshrc
, it fails if remote_user
is not root.
I don't know how to do the (2)
Obviously, the (3) should be in your hands...
I wanted to open a Pull Request, modifying the task and using owner: '{{ item.username }}'
instead of become_user: '{{ item.username }}'
, but I discovered this was the case before and has been changed in 02c7f16.
I understand that setting the owner of file is easy, but setting the corresponding primary group is challenging since it is not always the same "word".
I discovered there is some unix commands that can determine the primary group of a user, but I don't know which way to follow to resolve this issue.
What do you think ?
Testing Ansible roles manually with Docker is a bit of a pain; Molecule (http://molecule.readthedocs.io/) makes it easy. It also provides a way to unify local unit testing with the tests ran by Travis CI.
Configure the project for running Molecule and change the Travis CI build to use Molecule.
If acl
package is missing on system, ansible cant use setfacl
, so trying chmod instead, that cant be used on another unpriveleged user with template module. More here. After installing that package on system, everything works fine
Hi,
Here is my play book
- name: run role for each user
include_role:
name: gantsign.oh-my-zsh
vars:
users:
- username: root
oh_my_zsh:
theme: gnzh
plugins:
- git
- zsh-syntax-highlighting
- zsh-autosuggestions
- docker
The zsh-autosuggestions is in plugins but it does not autocomplete. Do I need to install something else beside the playbook?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.