My public, perhaps useful, ansible scripts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Dan Langille b69de0f2c4 Update 'README.md' 3 weeks ago
files Add scripts for converting user from bash to zsh 3 weeks ago
templates Add scripts for converting user from bash to zsh 3 weeks ago
README.md Update 'README.md' 3 weeks ago
convert-bash-to-zsh.yml Add scripts for converting user from bash to zsh 3 weeks ago

README.md

Dan's ansible scripts

convert-bash-to-zsh.yml

This script converts a user's shell from bash to zsh, including conversion of shell history. Existing files are not removed.

Everyone gets the same ~/.zshrc file

Here is a sample run.

Some explanations:

  • convert-bash-to-zsh.yml - script to run

  • zsh_user=dan - convert dan's account to a zsh shell

  • pg13 - do this only on the host pg13

    # ansible-playbook convert-bash-to-zsh.yml --extra-vars="zsh_user=dan" --limit=pg13
    
    PLAY [*] *****************************************
    
    TASK [Gathering Facts] ***************************
    ok: [pg13]
    
    TASK [install .zshrc file] ***********************
    changed: [pg13]
    
    TASK [install zsh] *******************************
    changed: [pg13]
    
    TASK [Copy bash history conversion script] *******
    changed: [pg13]
    
    TASK [conversion script] *************************
    changed: [pg13]
    
    TASK [convert bash history] **********************
    changed: [pg13]
    
    TASK [remove history conversion script] **********
    changed: [pg13]
    
    TASK [remove conversion script] ******************
    changed: [pg13]
    
    TASK [Set shell] *********************************
    changed: [pg13]
    
    PLAY RECAP ***************************************
    pg13 : ok=9    changed=8    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
    

The files

  • files/bash-to-zsh-hist.py - the Python script which converts ~/.bash_history to ~/.zsh_history
  • convert-bash-to-zsh.yml - the Ansible playbook which does the work
  • .#README.md - this file
  • templates/zshrc.j2 - my .zshrc template file - currently has no Ansible variables
  • templates/run-bash-to-zsh-hist.sh.j2 - simple shell script to invoke the Python script. I'm sure it can be done all from the playbook without this shell script, but I didn't want to mess around with it. I wanted it done. Patches welcome.