Add shell play book to install zsh and oh-my-zsh.

main
greatbody 2023-03-03 17:09:02 +08:00
parent ccfd2e305c
commit 0cd0af20d4
No known key found for this signature in database
GPG Key ID: 01CEB6267272A9A5
2 changed files with 44 additions and 0 deletions

View File

@ -35,5 +35,8 @@
- name: Install docker - name: Install docker
ansible.builtin.import_playbook: src/docker.yml ansible.builtin.import_playbook: src/docker.yml
- name: Manage Shell
ansible.builtin.import_playbook: src/shell.yml
- name: Run sudo without password - name: Run sudo without password
ansible.builtin.import_playbook: src/sudonopass.yml ansible.builtin.import_playbook: src/sudonopass.yml

41
src/shell.yml Normal file
View File

@ -0,0 +1,41 @@
---
- name: Maintain Shell configuration
hosts: linux
become: true
become_user: sunrui
vars:
user: "sunrui"
tasks:
- name: Zsh
apt:
name: zsh
state: present
- name: Set zsh as default shell
become: true
user:
name: "{{ user }}"
shell: /usr/bin/zsh
- name: Install oh-my-zsh
become: true
git:
repo: https://github.com/ohmyzsh/ohmyzsh.git
dest: /home/{{ user }}/.oh-my-zsh
clone: true
force: true
- name: Install zsh-autosuggestions plugin
become: true
git:
repo: https://github.com/zsh-users/zsh-autosuggestions.git
dest: /home/{{ user }}/.oh-my-zsh/custom/plugins/zsh-autosuggestions
clone: true
force: true
register: autosuggestions
- name: Configure zsh-autosuggestions plugin
become: true
lineinfile:
path: /home/{{ user }}/.zshrc
regexp: '^plugins='
line: 'plugins=(git zsh-autosuggestions)'
when: autosuggestions.changed