Skip to content

Instantly share code, notes, and snippets.

@tabrez
Created August 1, 2023 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tabrez/bf48acd20525a0d86168d9b769addf31 to your computer and use it in GitHub Desktop.
Save tabrez/bf48acd20525a0d86168d9b769addf31 to your computer and use it in GitHub Desktop.
Bash script that allows picking what roles to install on a machine using ansible
#!/bin/bash
# Define an array of roles
roles=(
"ansible",
"copy-private-ssh-key",
"copy-public-ssh-key",
"password-less-sudo",
"ssh-config",
"config-local",
"utils",
"neovim",
"astrovim",
"docker",
"multipass",
"setup-root",
"jupyterlab"
# "ssh-server",
# "packer",
# "terraform",
# "vscode-extensions",
# "megacmd",
# "nfs-fstab"
# "smb-fstab"
)
# Build the tags string by joining the roles with a comma
tags=$(IFS=,; echo "${roles[*]}")
# Run the ansible-playbook command with the specified tags
ansible-playbook -i hosts playbook.yml --tags "$tags"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment