# Ansible Commands Cheat Sheet

Here’s a list of common ansible commands…

Read through this DevOps book pdf for getting Docker and Ansible to work together: [https://bjpcjp.github.io/pdfs/devops/ansible-docker.pdf](https://bjpcjp.github.io/pdfs/devops/ansible-docker.pdf "https://bjpcjp.github.io/pdfs/devops/ansible-docker.pdf")

## Host Setup<button aria-label="Copy link to heading" class="cc-1r0b9w7" type="button"><svg height="24" role="presentation" viewbox="0 0 24 24" width="24"></svg></button>

# Host Setup Playbook<button aria-label="Copy link to heading" class="cc-1r0b9w7" type="button"><svg height="24" role="presentation" viewbox="0 0 24 24" width="24"></svg></button>

This playbook will do basic setup of common packages and config that each host requires, such as ssl certs, permissions, and base packages.

It is run for each host by specifying the hostname in arguments.

```bash
ansible-playbook host-setup.yml -e "variable_host=wshost1" --ask-vault-pass
```

# Local Build Server Setup<button aria-label="Copy link to heading" class="cc-1r0b9w7" type="button"><svg height="24" role="presentation" viewbox="0 0 24 24" width="24"></svg></button>

These are playbook calls to set up the build server VM.

```bash
ansible-playbook buildserver.yml --ask-vault-pass
```

# Local Dev Host Setup<button aria-label="Copy link to heading" class="cc-1r0b9w7" type="button"><svg height="24" role="presentation" viewbox="0 0 24 24" width="24"></svg></button>

These are playbook calls to set up each development host with their particular build of services and config.

```bash
ansible-playbook dev-host1.yml --ask-vault-pass
ansible-playbook dev-host2.yml --ask-vault-pass
ansible-playbook dev-host3.yml --ask-vault-pass
```

# Cloud Dev Host Setup<button aria-label="Copy link to heading" class="cc-1r0b9w7" type="button"><svg height="24" role="presentation" viewbox="0 0 24 24" width="24"></svg></button>

These are playbook calls to set up each cloud development host with their particular build of services and config.

```bash
ansible-playbook dev-cldev1.yml --ask-vault-pass
ansible-playbook dev-cldev2.yml --ask-vault-pass
```

# Prod Host Setup<button aria-label="Copy link to heading" class="cc-1r0b9w7" type="button"><svg height="24" role="presentation" viewbox="0 0 24 24" width="24"></svg></button>

These are playbook calls to set up each production host with their particular build of services and config.

```bash
ansible-playbook prod-host1.yml --ask-vault-pass
ansible-playbook prod-host2.yml --ask-vault-pass
ansible-playbook prod-host3.yml --ask-vault-pass
ansible-playbook prod-host4.yml --ask-vault-pass
ansible-playbook prod-host5.yml --ask-vault-pass
ansible-playbook prod-host6.yml --ask-vault-pass
```

### Personal Host Cluster Setup

Here is how to run commands on the PHC.

```bash
ansible-playbook phc-admin01-rundk-admin-webui.yml --extra-vars "ansible_become_pass=password" --extra-vars "jenkins_password=password"
ansible-playbook phc-backups01-rundk-backups-webui.yml --extra-vars "ansible_become_pass=password" --extra-vars "jenkins_password=password"
```

<div class="code-block  cc-wroouh" id="bkmrk-"></div>