Skip to content

Instantly share code, notes, and snippets.

@bgruszka
Last active December 15, 2017 09:31
Show Gist options
  • Save bgruszka/a3cd33be034151871303f29495baddef to your computer and use it in GitHub Desktop.
Save bgruszka/a3cd33be034151871303f29495baddef to your computer and use it in GitHub Desktop.
  • vagrant up

  • vagrant ssh

  • sudo -i

  • pip install ansible

  • pip install lxc-python2

  • lxc-create -n db1 -t ubuntu

  • lxc-start -n db1 -d

  • lxc-create -n web1 -t ubuntu

  • lxc-start -n web1 -d

  • lxc-create -n web2 -t ubuntu

  • lxc-start -n web2 -d

ssh-keygen

cat ~/.ssh/id_rsa.pub

ssh ubuntu@web1.ip ssh ubuntu@web2.ip ssh ubuntu@db1.ip

sudo -i ssh root@localhost vim ~/.ssh/authorized_keys

[defaults] host_key_checking = False


Ad hoc commands:

ansible <group/machine> -m -a (-k for ask-pass)

ansible allmachines -m ping -u root -k ansible allmachines -a "free -m" -i inventory -u root ansible web -a "apt-get -y install nginx" ansible web -m package -a "name=nginx state=restarted" -i inventory -u root ansible web -m package -a "name=nginx state=installed" -i inventory -u root


lxc-create -n playbooks -t ubuntu lxc-start -n playbooks -d

ansible-playbook prepare_ansible_target.yml -i inventory -u ubuntu -k --ask-sudo-pass


ansible allservers -m setup -u root -i inventory

———— ansible-playbook -i "localhost," -c local lxc.yml

sudo iptables -t nat -I PREROUTING -p tcp -d 192.168.33.10 --dport 80 -j DNAT --to 10.0.3.69:80

#sudo iptables -A FORWARD -p tcp -d 10.0.3.116 --dport 25565 -j ACCEPT

---
- hosts: all
gather_facts: False
remote_user: ubuntu
becomes: yes
become_user: root
become_method: sudo
tasks:
- name: Install Python 2
- raw: test -e /usr/bin/python || (apt-get update && apt-get install -y python)
- name: Fancy way of doing authorized_keys
authorized_key: user=root exclusive=no key={{ lookup('file', '~/.ssh/id_rsa.pub') }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment