Skip to content

Commit

Permalink
feat: added the ability to run arbitrary scripts (#17)
Browse files Browse the repository at this point in the history
* feat: added the ability to run arbitrary scripts

* docs(README): updated documentation
  • Loading branch information
AlexNabokikh authored May 19, 2023
1 parent c5a264b commit f04ca07
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
cp tests/ansible.cfg ./ansible.cfg
cp tests/inventory ./inventory
cp tests/test_config.yml ./config.yml
cp tests/.install.sh /home/runner/.install.sh
ansible-galaxy install -r requirements.yml
- name: Test the playbook's syntax
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
![badge-gh-release]
![badge-license]

This playbook helps to configure Ubuntu machine(s) for daily usage or software development quickly.
This playbook helps to configure Ubuntu or any other Debian-based distro machine(s) for daily usage or software development quickly.

## Contents

Expand All @@ -26,20 +26,22 @@ This playbook helps to configure Ubuntu machine(s) for daily usage or software d
- Clone a set of **dotfiles** from a given Git repo and link them to the users' home directory. ([Role](https://github.com/geerlingguy/ansible-role-dotfiles))
- **System Settings**
- **hostname**
- Create a user-defined hostname.
- Set a user-defined hostname.
- **directories**
- Create custom user directories.
- **sudoers**
- Apply custom user sudoers config.
- **fonts**
- Download and install Nerd Fonts.
- Download and install [Nerd Fonts](https://github.com/ryanoasis/nerd-fonts).
- **ZSH**
- Install and configure **ZSH** and **Oh-My-ZSH**
- Install custom **OMZ** plugins and themes.
- **TMUX**
- Install and configure **TMUX** and **TPM** (Plugin manager)
- **GNOME**
- Customizes the GNOME desktop ([Role](https://github.com/PeterMosmans/ansible-role-customize-gnome/))
- **User Script**
- Execute arbitrary user script.

## Installation

Expand Down
4 changes: 4 additions & 0 deletions example.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,7 @@ pip_packages:
npm_packages:
- name: neovim
state: latest

# Execute dotfiles script
execute_script: false
user_script: ~/.install.sh
Binary file modified files/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,9 @@
file: tasks/zsh.yml
when: configure_zsh
tags: ["zsh"]

- name: Include user script task configuration.
ansible.builtin.import_tasks:
file: tasks/user_script.yml
when: execute_script
tags: ["script"]
4 changes: 4 additions & 0 deletions tasks/user_script.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
- name: Execute arbitrary user script.
ansible.builtin.command: "{{ user_script }}"
changed_when: false
25 changes: 25 additions & 0 deletions tests/.install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail
if [[ "${TRACE-0}" == "1" ]]; then
set -o xtrace
fi

if [[ "${1-}" =~ ^-*h(elp)?$ ]]; then
echo 'Usage: ./.install.sh arg-one arg-two
This is a test bash script.
'
exit
fi

cd "$(dirname "$0")"

main() {
echo "Test has been completed"
}

main "$@"
3 changes: 3 additions & 0 deletions tests/test_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ zsh_themes:

configure_tmux: true
tmux_dir: $HOME/.tmux

execute_script: true
user_script: ~/.install.sh

0 comments on commit f04ca07

Please sign in to comment.