Skip to content

Instantly share code, notes, and snippets.

@yudapc

yudapc/Ansibel Secret

Last active February 3, 2016 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yudapc/1fed3b47efef049fdaed to your computer and use it in GitHub Desktop.
Save yudapc/1fed3b47efef049fdaed to your computer and use it in GitHub Desktop.
Ansibel
$ sudo apt-get install python-pip
$ sudo pip install boto
$ sudo pip install https://github.com/KMK-ONLINE/ansible/zipball/elasticache_redis_vpc
create new file with name "hostfile" :
[yudaserver]
128.199.146.166
create new file with name "nginx.yml" :
- name: DEPLOYMENT
hosts: yudaserver
sudo: yes
user: cog
gather_facts: yes
tasks:
- name: Install Nginx
apt: pkg={{item}} update_cache=yes state=latest
with_items:
- nginx
- php5-fpm
oke, right now we can running ansible-playbook:
$ ansible-playbook nginx.yml -i hostfile -v
COPY SSH_KEY To server, and make sure ssh to server without password,run this command in your local machine
$ ssh-keygen -t rsa
$ ssh-copy-id cog@d.boxgue.com
$ ssh cog@d.boxgue.com
test your connection to yudaserver
$ ansible yudaserver -i hostfile -m ping
ssh to yudaserver. and edit file "/etc/sudoers" if we want passwordless to sudo :
$ sudo vim /etc/sudoers
cog ALL=(ALL:ALL) NOPASSWD: ALL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment