Skip to content

Instantly share code, notes, and snippets.

@theodorosploumis
Last active May 5, 2022 15:32
Show Gist options
  • Save theodorosploumis/49372ce118591096a6ee to your computer and use it in GitHub Desktop.
Save theodorosploumis/49372ce118591096a6ee to your computer and use it in GitHub Desktop.
Simple Ansible ad-hoc commands for Shared Hosting
// Inventory name is "hosts"
// Example of inventory
[group]
SERVER_NAME ansible_connection=ssh ansible_ssh_user=SSH_USER ansible_python_interpreter=PATH_TO_REMOTE
_PYTHON
// List hosts
ansible -i hosts all --list-hosts
// Show info for each host
ansible -i hosts all -m setup
// Ping all hosts (module ping)
ansible all -i hosts -m ping
// Run `pwd` on shell
ansible all -i hosts -m shell -a "pwd"
// Use drush
ansible all -i hosts -m shell -a "cd test.com/www; ~/drush/drush dl drupal"
ansible all -i hosts -m shell -a "cd test.com/www; ~/drush/drush up drupal"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment