我正在使用Ansible配置和部署一个运行 MongoDB 的 EC2 实例。
我现在想知道如何将 MongoDB 配置为在 EC2 实例重新启动后自动重新启动。还是我只需要重新运行 Ansible Playbook?
这是我目前的Ansible 剧本:
- hosts: staging_mongodb
user: ec2-user
sudo: yes
vars_files:
- vars/mongodb.yml
tasks:
- name: Check NTP
action: service name=ntpd state=started
- name: Copy MongoDB repo file
action: copy src=files/10gen.repo dest=/etc/yum.repos.d/10gen.repo
- name: Install MongoDB
action: yum pkg=mongo-10gen state=latest
- name: Install MongoDB server
action: yum pkg=mongo-10gen-server state=latest
- name: Template the MongoDB configuration file
action: template src=templates/mongod.conf.j2 dest=/etc/mongod.conf
- name: Prepare the database directory
action: file path=${db_path} state=directory recurse=yes owner=mongod group=mongod mode=0755
- name: Configure MongoDB
action: service name=mongod state=started enabled=yes