使用Ansible安装Mongodb
我顺便也安装了zsh。
- hosts: all
user: ubuntu
vars:
tasks:
- name: zsh install
command: sudo apt-get install zsh
- name: mongo install 1
command: sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
- name: mongo install 2
shell:
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
- name: update
command: sudo apt-get update
- name: mongo install 3
command: sudo apt-get install mongodb-org=2.6.4 mongodb-org-server=2.6.4 mongodb-org-shell=2.6.4 mongodb-org-mongos=2.6.4 mongodb-org-tools=2.6.4
- name: mongo install 4
shell: echo "{{ item }} hold" | sudo dpkg --set-selections
with_items:
- mongodb-org
- mongodb-org-server
- mongodb-org-shell
- mongodb-org-mongos
- mongodb-org-tools
Mongo安裝時,有3個部分非常冗長,讓我擔心是否能正常運作,但幸運地成功了。以下是成功的輸出。
ubuntu@aws1:~/aws$ ansible-playbook server_setup_ubuntu14.04.yml
PLAY [all] ********************************************************************
GATHERING FACTS ***************************************************************
ok: [ubuntu@aws6]
ok: [ubuntu@aws3]
ok: [ubuntu@aws5]
ok: [ubuntu@aws2]
ok: [ubuntu@aws4]
TASK: [zsh install] ***********************************************************
changed: [ubuntu@aws4]
changed: [ubuntu@aws2]
changed: [ubuntu@aws3]
changed: [ubuntu@aws5]
changed: [ubuntu@aws6]
TASK: [mongo install 1] *******************************************************
changed: [ubuntu@aws2]
changed: [ubuntu@aws3]
changed: [ubuntu@aws4]
changed: [ubuntu@aws5]
changed: [ubuntu@aws6]
TASK: [mongo install 2] *******************************************************
changed: [ubuntu@aws2]
changed: [ubuntu@aws3]
changed: [ubuntu@aws6]
changed: [ubuntu@aws4]
changed: [ubuntu@aws5]
TASK: [update] ****************************************************************
changed: [ubuntu@aws2]
changed: [ubuntu@aws3]
changed: [ubuntu@aws6]
changed: [ubuntu@aws4]
changed: [ubuntu@aws5]
TASK: [mongo install 3] *******************************************************
changed: [ubuntu@aws2]
changed: [ubuntu@aws6]
changed: [ubuntu@aws5]
changed: [ubuntu@aws3]
changed: [ubuntu@aws4]
TASK: [mongo install 4] *******************************************************
changed: [ubuntu@aws4] => (item=mongodb-org)
changed: [ubuntu@aws3] => (item=mongodb-org)
changed: [ubuntu@aws2] => (item=mongodb-org)
changed: [ubuntu@aws2] => (item=mongodb-org-server)
changed: [ubuntu@aws5] => (item=mongodb-org)
changed: [ubuntu@aws6] => (item=mongodb-org)
changed: [ubuntu@aws4] => (item=mongodb-org-server)
changed: [ubuntu@aws3] => (item=mongodb-org-server)
changed: [ubuntu@aws6] => (item=mongodb-org-server)
changed: [ubuntu@aws5] => (item=mongodb-org-server)
changed: [ubuntu@aws3] => (item=mongodb-org-shell)
changed: [ubuntu@aws2] => (item=mongodb-org-shell)
changed: [ubuntu@aws6] => (item=mongodb-org-shell)
changed: [ubuntu@aws4] => (item=mongodb-org-shell)
changed: [ubuntu@aws6] => (item=mongodb-org-mongos)
changed: [ubuntu@aws3] => (item=mongodb-org-mongos)
changed: [ubuntu@aws4] => (item=mongodb-org-mongos)
changed: [ubuntu@aws5] => (item=mongodb-org-shell)
changed: [ubuntu@aws2] => (item=mongodb-org-mongos)
changed: [ubuntu@aws6] => (item=mongodb-org-tools)
changed: [ubuntu@aws3] => (item=mongodb-org-tools)
changed: [ubuntu@aws4] => (item=mongodb-org-tools)
changed: [ubuntu@aws5] => (item=mongodb-org-mongos)
▽
ssh-rsa hogehogehogehgoehgoeogehoegheogheogheohoegheogheogheogheog: [ubuntu@aws2] => (item=mongodb-org-tools)
changed: [ubuntu@aws5] => (item=mongodb-org-tools)
PLAY RECAP ********************************************************************
ubuntu@aws2 : ok=7 changed=6 unreachable=0 failed=0
ubuntu@aws3 : ok=7 changed=6 unreachable=0 failed=0
ubuntu@aws4 : ok=7 changed=6 unreachable=0 failed=0
ubuntu@aws5 : ok=7 changed=6 unreachable=0 failed=0
ubuntu@aws6 : ok=7 changed=6 unreachable=0 failed=0