Ansible cheat sheet » History » Version 4
Jon Goldberg, 07/01/2021 02:43 PM
| 1 | 1 | Jon Goldberg | {{last_updated_at}} by {{last_updated_by}} |
|---|---|---|---|
| 2 | |||
| 3 | # Ansible cheat sheet |
||
| 4 | |||
| 5 | 3 | Irene Meisel | This page will cover some helpful one-line commands we can execute with Ansible to accomplish various tasks. Always run **git pull** and **git submodule update** before executing these commands. |
| 6 | 1 | Jon Goldberg | |
| 7 | 4 | Jon Goldberg | #### Roll back a site to the latest commit (e.g. after a failed merge): |
| 8 | 1 | Jon Goldberg | ```shell |
| 9 | ansible --become -m shell -a 'cd {{civiroot}} && git clean -fdx {{civiroot}} && get reset --hard HEAD' mysite1.local,mysite2.local |
||
| 10 | ``` |
||
| 11 | 2 | Jon Goldberg | |
| 12 | 4 | Jon Goldberg | #### Synchronize a non-canonical site with the live site's database |
| 13 | 2 | Jon Goldberg | ``` |
| 14 | ansible-playbook main-playbook.yml --tags site-db-sync -l mysite.local |
||
| 15 | ``` |
||
| 16 | * This works on test and live sites. |
||
| 17 | 1 | Jon Goldberg | * Depending on the sync strategy on the website inventory, it will pull from last night's backup, or sync directly from the live site. |
| 18 | * Only sites that pull from backup can sync to a site that's not on your local machine at present (I'll fix this at some point). |
||
| 19 | 4 | Jon Goldberg | |
| 20 | #### Revert a failed local update |
||
| 21 | ```shell |
||
| 22 | ansible '*.local' -m shell -a "cd {{webroot}} && git checkout ." --become --become-user "{{ run_as_user }}" |
||
| 23 | ``` |