Skip to content

Latest commit

 

History

History
72 lines (44 loc) · 1.11 KB

README.md

File metadata and controls

72 lines (44 loc) · 1.11 KB

Simple Format

.
├── inventory
│   └── hosts_vars
│       └── hosts.ini
├── roles
│   └── docker
│       └── tasks
│           └── main.yml
└── site.yml

/

Simple Command

# without sudo password 
$ ansible-playbook --inventory ./inventory/hosts_vars/hosts.ini site.yml 


# with sudo password
$ ansible-playbook --inventory ./inventory/hosts_vars/hosts.ini site.yml --ask-become-pass
#define tags in playbooks site.yml
  roles:
    - {role: mysql, tags: ['db']}
    - {role: mongo, tags: ['db']}
    - {role: docker, tags: ['docker']}
#tag based roles 
ansible-playbook --inventory ./inventory/hosts_vars/hosts.ini site.yml --tags docker ... #<any tag>

Add SSH key to target

# Generate SSH Key
$ ssh-keygen
> ... (add path and name of key and all)

# copy .pub to target authorized_keys 
$ ssh-copy-id -i <path_to_new_generated_key.pub> uname@<ip>

# ADD ssh key in ansible hosts file
# Example
[hosts-name]
192.168.0.108 ansible_ssh_private_key_file=<path_to_privet-key>

# Ezz ;)))