|
2 | 2 | - name: check to see that MongoDB 2.4 is not installed
|
3 | 3 | stat: path=/etc/init.d/mongodb
|
4 | 4 | register: mongodb_needs_upgrade
|
| 5 | + tags: |
| 6 | + - install |
| 7 | + - install:base |
5 | 8 |
|
6 | 9 | - name: verify 2.4 not installed
|
7 | 10 | fail: msg="MongoDB 2.4 is currently installed and cannot be safely upgraded in a clustered configuration. Please read http://docs.mongodb.org/manual/release-notes/2.6-upgrade/#upgrade-considerations and upgrade to 2.6."
|
8 | 11 | when: mongodb_needs_upgrade.stat.exists and MONGO_CLUSTERED
|
| 12 | + tags: |
| 13 | + - install |
| 14 | + - install:base |
9 | 15 |
|
10 | 16 | - name: remove mongo 2.4 if present
|
11 | 17 | apt: >
|
12 | 18 | pkg=mongodb-10gen
|
13 | 19 | state=absent purge=yes
|
14 | 20 | force=yes
|
15 | 21 | when: mongodb_needs_upgrade.stat.exists and not MONGO_CLUSTERED
|
| 22 | + tags: |
| 23 | + - install |
| 24 | + - install:base |
16 | 25 |
|
17 | 26 | - name: install python pymongo for mongo_user ansible module
|
18 | 27 | pip: >
|
19 | 28 | name=pymongo state=present
|
20 | 29 | version={{ pymongo_version }} extra_args="-i {{ COMMON_PYPI_MIRROR_URL }}"
|
| 30 | + tags: |
| 31 | + - install |
| 32 | + - install:base |
21 | 33 |
|
22 | 34 | - name: add the mongodb signing key
|
23 | 35 | apt_key: >
|
24 | 36 | id={{ MONGODB_APT_KEY }}
|
25 | 37 | keyserver={{ MONGODB_APT_KEYSERVER }}
|
26 | 38 | state=present
|
| 39 | + tags: |
| 40 | + - install |
| 41 | + - install:base |
27 | 42 |
|
28 | 43 | - name: add the mongodb repo to the sources list
|
29 | 44 | apt_repository: >
|
30 | 45 | repo='{{ MONGODB_REPO }}'
|
31 | 46 | state=present
|
| 47 | + tags: |
| 48 | + - install |
| 49 | + - install:base |
32 | 50 |
|
33 | 51 | - name: install mongo server and recommends
|
34 | 52 | apt: >
|
35 | 53 | pkg=mongodb-org={{ mongo_version }}
|
36 | 54 | state=present install_recommends=yes
|
37 | 55 | force=yes update_cache=yes
|
| 56 | + tags: |
| 57 | + - install |
| 58 | + - install:base |
38 | 59 |
|
39 | 60 | - name: create mongo dirs
|
40 | 61 | file: >
|
|
46 | 67 | - "{{ mongo_dbpath }}"
|
47 | 68 | - "{{ mongo_log_dir }}"
|
48 | 69 | - "{{ mongo_journal_dir }}"
|
| 70 | + tags: |
| 71 | + - install |
| 72 | + - install:base |
49 | 73 |
|
50 | 74 | - name: stop mongod service
|
51 | 75 | service: name=mongod state=stopped
|
| 76 | + tags: |
| 77 | + - manage |
| 78 | + - manage:stop |
52 | 79 |
|
53 | 80 | - name: move mongodb to {{ mongo_data_dir }}
|
54 | 81 | command: >
|
55 | 82 | mv /var/lib/mongodb {{ mongo_data_dir}}/.
|
56 | 83 | creates={{ mongo_data_dir }}/mongodb
|
| 84 | + tags: |
| 85 | + - install |
| 86 | + - install:base |
57 | 87 |
|
58 | 88 | - name: copy mongodb key file
|
59 | 89 | copy: >
|
|
63 | 93 | owner=mongodb
|
64 | 94 | group=mongodb
|
65 | 95 | when: MONGO_CLUSTERED
|
| 96 | + tags: |
| 97 | + - install |
| 98 | + - install:configuration |
66 | 99 |
|
67 | 100 | - name: copy configuration template
|
68 | 101 | template: src=mongodb.conf.j2 dest=/etc/mongod.conf backup=yes
|
69 | 102 | notify: restart mongo
|
| 103 | + tags: |
| 104 | + - install |
| 105 | + - install:configuration |
70 | 106 |
|
71 | 107 | - name: start mongo service
|
72 | 108 | service: name=mongod state=started
|
| 109 | + tags: |
| 110 | + - manage |
| 111 | + - manage:start |
73 | 112 |
|
74 | 113 | - name: wait for mongo server to start
|
75 | 114 | wait_for: port=27017 delay=2
|
| 115 | + tags: |
| 116 | + - manage |
| 117 | + - manage:start |
76 | 118 |
|
77 | 119 | - name: drop super user script
|
78 | 120 | template: src="create_root.js.j2" dest="/tmp/create_root.js"
|
79 | 121 | when: not MONGO_CLUSTERED
|
| 122 | + tags: |
| 123 | + - install |
| 124 | + - install:configuration |
80 | 125 |
|
81 | 126 | - name: create super user with js
|
82 | 127 | shell: >
|
83 | 128 | /usr/bin/mongo admin /tmp/create_root.js
|
84 | 129 | when: not MONGO_CLUSTERED
|
| 130 | + tags: |
| 131 | + - install |
| 132 | + - install:configuration |
85 | 133 |
|
86 | 134 | - name: delete super user script
|
87 | 135 | file: path=/tmp/create_root.js state=absent
|
88 | 136 | when: not MONGO_CLUSTERED
|
| 137 | + tags: |
| 138 | + - install |
| 139 | + - install:configuration |
89 | 140 |
|
90 | 141 | - name: Create the file to initialize the mongod replica set
|
91 | 142 | template: src=repset_init.js.j2 dest=/tmp/repset_init.js
|
92 | 143 | when: MONGO_CLUSTERED
|
| 144 | + tags: |
| 145 | + - install |
| 146 | + - install:configuration |
93 | 147 |
|
94 | 148 | - name: Initialize the replication set
|
95 | 149 | shell: >
|
96 | 150 | /usr/bin/mongo /tmp/repset_init.js
|
97 | 151 | when: MONGO_CLUSTERED
|
| 152 | + tags: |
| 153 | + - install |
| 154 | + - install:configuration |
98 | 155 |
|
99 | 156 | #- name: delete repset script
|
100 | 157 | # file: path=/tmp/repset_init.js state=absent
|
|
111 | 168 | state=present
|
112 | 169 | with_items: MONGO_USERS
|
113 | 170 | when: not MONGO_CLUSTERED
|
| 171 | + tags: |
| 172 | + - manage |
| 173 | + - manage:app-users |
114 | 174 |
|
115 | 175 | - name: create a mongodb user
|
116 | 176 | mongodb_user: >
|
|
124 | 184 | replica_set={{ mongo_repl_set }}
|
125 | 185 | with_items: MONGO_USERS
|
126 | 186 | when: MONGO_CLUSTERED
|
| 187 | + tags: |
| 188 | + - manage |
| 189 | + - manage:app-users |
127 | 190 |
|
128 | 191 | - name: install s3cmd
|
129 | 192 | pip: >
|
130 | 193 | name="s3cmd"
|
131 | 194 | state=present
|
132 | 195 | extra_args="-i {{ COMMON_PYPI_MIRROR_URL }}"
|
133 | 196 | when: MONGO_S3_BACKUP
|
| 197 | + tags: |
| 198 | + - install |
| 199 | + - install:app-requirements |
134 | 200 |
|
135 | 201 | - name: configure s3cmd
|
136 | 202 | template: >
|
|
140 | 206 | group=root
|
141 | 207 | mode=0600
|
142 | 208 | when: MONGO_S3_BACKUP
|
| 209 | + tags: |
| 210 | + - install |
| 211 | + - install:configuration |
143 | 212 |
|
144 | 213 | - name: install backup-mongo-to-s3 script
|
145 | 214 | template: >
|
|
149 | 218 | group=root
|
150 | 219 | mode=0700
|
151 | 220 | when: MONGO_S3_BACKUP
|
| 221 | + tags: |
| 222 | + - install |
| 223 | + - install:configuration |
152 | 224 |
|
153 | 225 | - name: schedule backup-mongo-to-3s crontab
|
154 | 226 | cron:
|
|
161 | 233 | minute="0"
|
162 | 234 | day="{{ MONGO_S3_BACKUP_DAY }}"
|
163 | 235 | when: MONGO_S3_BACKUP
|
| 236 | + tags: |
| 237 | + - install |
| 238 | + - install:configuration |
0 commit comments