An Ansible module that interacts with GNU Stow packages.
This ansible module is tested against the following versions:
| Program | Compatible versions |
|---|---|
ansible |
2.10.7, 3.4.0, 4.10.0, 5.4.0, 6.7.0, 7.7.0, 8.7.0, 9.13.0, 10.7.0, 11.13.0, 12.3.0, 13.2.0 |
python |
3.7.x, 3.8.x, 3.9.x, 3.10.x, 3.11.x, 3.12.x, 3.13.x |
stow |
2.3.1, 2.4.0 |
For python < 3 (legacy systems that still uses 2.x), use the v0.1.3 of this module.
For linting and other code verifications, python >= 3.10 is required.
To use ansible-stow, the managed node should have stow installed.
GNU Stow is widely available in all major distributions and can be
installed with apt-get, pacman, yum etc.
Download the module and move it into your global Ansible library or into the library directory alongside your top-level playbook. E.g.:
$ wget https://raw.githubusercontent.com/caian-org/ansible-stow/v1.2.1/stow.py
$ (sudo) mv stow.py /usr/share/ansible| Parameter | Required | Choices / Defaults | Comments |
|---|---|---|---|
package |
yes | Name of the Stow package | |
target |
no | Default: user's home directory | Path of target directory to perform |
folding |
no | Default: True | Symlink highest non-existing directory (False to create directories and symlink only the file) |
dir |
yes | Path of the Stow directory | |
state |
yes |
Choices:
|
|
# stow package "zsh" of directory "/media/user/dots" to the home directory
- stow:
state: present
package: zsh
dir: /media/user/dots
target: '$HOME'
# remove package "tmux"
- stow:
state: absent
package: tmux
dir: /media/user/dots
# in case of conflict, overwrite the file with a symlink
- stow:
state: supress
package: vim
dir: /media/user/dots
# loop through list of packages
- stow:
state: latest
package: '{{ item }}'
dir: /media/user/dots
with_items:
- zsh
- tmux
- i3- If the package target already exists on the node filesystem as a file or a
symbolic link, the
supressstate will delete/unlink the target and then stow the package. - If the package target already exists and is a directory,
ansible-stowwill fail -- even using thesupressstate. This is an implementation decision. - Stow cannot handle the tilde expansion (
~). Use the$HOMEenvironment variable instead or Ansible's template functionlookup.
Original implementation by Ric da Silva.
To the extent possible under law, Caian Ertl has waived all copyright
and related or neighboring rights to this work. In the spirit of freedom of
information, I encourage you to fork, modify, change, share, or do whatever
you like with this project! ^C ^V