-
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