Coder Social home page Coder Social logo

geerlingguy / ansible-role-dotfiles Goto Github PK

View Code? Open in Web Editor NEW
222.0 7.0 102.0 33 KB

Ansible Role - Easy and flexible dotfile installation.

Home Page: https://galaxy.ansible.com/geerlingguy/dotfiles/

License: MIT License

ansible role dotfiles configuration development

ansible-role-dotfiles's Introduction

Ansible Role: Dotfiles

CI

Installs a set of dotfiles from a given Git repository. By default, it will install my (geerlingguy's) dotfiles, but you can use any set of dotfiles you'd like, as long as they follow a conventional format.

Requirements

Requires git on the managed machine (you can easily install it with geerlingguy.git if required).

Role Variables

Available variables are listed below, along with default values (see defaults/main.yml):

dotfiles_repo: "https://github.com/geerlingguy/dotfiles.git"
dotfiles_repo_version: master

The git repository and branch/tag/commit hash to use for retrieving dotfiles. Dotfiles should generally be laid out within the root directory of the repository.

dotfiles_repo_accept_hostkey: false

Add the hostkey for the repo url if not already added. If ssh_opts contains "-o StrictHostKeyChecking=no", this parameter is ignored.

dotfiles_repo_local_destination: "~/Documents/dotfiles"

The local path where the dotfiles_repo will be cloned.

dotfiles_home: "~"

The home directory where dotfiles will be linked. Generally, the default should work, but in some circumstances, or when running the role as sudo on behalf of another user, you may want to specify the full path.

dotfiles_files:
  - .zshrc
  - .gitignore
  - .inputrc
  - .vimrc

Which files from the dotfiles repository should be linked to the dotfiles_home.

Dependencies

None

Example Playbook

- hosts: localhost
  roles:
    - { role: geerlingguy.dotfiles }

License

MIT / BSD

Author Information

This role was created in 2015 by Jeff Geerling, author of Ansible for DevOps.

ansible-role-dotfiles's People

Contributors

geerlingguy avatar newtonne 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

ansible-role-dotfiles's Issues

Add a directory to `dotfiles_files`

Use Case

Some configs can be spread across multiple files in a folder. For example, neovim configs can consist an init.vim or init.lua and multiple other .vim or .lua files. It would be useful if we can track the entire folder with a wildcard:

dotfiles_files:
  - .config/nvim/*

DEPRECATION WARNING: always_run is deprecated

Obviously, this needs to be updated....

[DEPRECATION WARNING]: always_run is deprecated. Use check_mode = no instead..
This feature will be removed in version 2.4. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

The specific section is:

- name: Ensure all configured dotfiles are links.
  shell: "ls -F {{ dotfiles_home }}/{{ item }}"
  register: existing_dotfile_info
  failed_when: false
  always_run: yes
  changed_when: false
  with_items: "{{ dotfiles_files }}"

Support filenames without leading `.`

I like to keep my dotfiles without the leading dot in my git repository. It would be nice if this role could handle this when creating the links, so for example vimrc in the git repo should be linked to ~/.vimrc.

Add variable to specify which private key should be used.

Hi,

do you think it would make sense to add a variable that defines which private key the ansible-git-module should use when accessing github?

This is only necessary for people who like to or have to use different ssh keys.
Adding key_file: ... to the "Ensure dotfiles repository is cloned locally."-task does the trick for me.
having this as a variable seems useful. If you agree I would create a PR.

Support symlinking files in directories.

I'll open up a PR later, this should be solvable with:

- name: Ensure dotfile directories exist.
  file:
    path: "{{ (dotfiles_home + '/' + item)|dirname }}"
    state: directory
  become: no
  with_items: "{{ dotfiles_files }}"

resets local repository to old state

I use this role as part of https://github.com/geerlingguy/mac-dev-playbook

So, here's my dotfiles directory before running the role:

 14:27:43 ~/Documents/dotfiles $ git status
On branch henning
Your branch is up-to-date with 'origin/henning'.
nothing to commit, working tree clean
 14:27:50 ~/Documents/dotfiles $ git log --max-count 1
commit 464510cda7f29fce31ae8bf88956533bea634303
Author: Henning Sprang <[email protected]>
Date:   Mon May 29 14:18:28 2017 +0100

    make some more adjustments

Then I run this role as part of the mac-development-playbook.

It does something like this:

TASK [geerlingguy.dotfiles : Ensure dotfiles repository is cloned locally.] ****
changed: [127.0.0.1]

So it changes the local clone nevertheless that this already exists and is perfectly up to date.

After this I have:

 14:31:28 ~/Documents/dotfiles $ git status
On branch henning
Your branch is behind 'origin/henning' by 5 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)
nothing to commit, working tree clean
 14:31:30 ~/Documents/dotfiles $ git log --max-count 1
commit cbb4d5508de7e7247cac88dec96e9ba870218547
Author: Henning Sprang <[email protected]>
Date:   Sat Apr 29 02:33:37 2017 +0200

    update homebrew github token

and my links to config files point to ourdated old versions. Which I do not want.

I'd expect the

Only works for `master` branch dot files

If the dot files repo doesn't have a master branch it will fail with:

TASK [geerlingguy.dotfiles : Ensure dotfiles repository is cloned locally.] *****************************************
fatal: [127.0.0.1]: FAILED! => {"changed": false, "cmd": "/usr/local/bin/git checkout --force master", "msg": "Failed to checkout master", "rc": 1, "stderr": "error: pathspec 'master' did not match any file(s) known to git\n", "stderr_lines": ["error: pathspec 'master' did not match any file(s) known to git"], "stdout": "", "stdout_lines": []}
The easiest solution is to just add a branch master to the repo.

That was good enough for me, so just adding the issue and closing for others if needed to reference or if someone wanted to add the feature.

Force symlinks

Hi, trying to symlink my .bash_profile is throwing an error in the task Link dotfiles into home folder in the second execution:
refusing to convert between file and link for /home/vagrant/.bash_profile

Adding force=true would fix the issue

Allow force override

Allow a force override for repos if needed. I have a tasks that adds a section to a dotfile. This section does not need to be kept in the repo as it varies for each person.

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.