diff --git a/galaxy.yml b/galaxy.yml index f46a3bb..e170c52 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -1,7 +1,7 @@ --- namespace: nephelaiio name: mongodb -version: 0.2.15 +version: 0.2.16 readme: README.md authors: - Ted Cook diff --git a/playbooks/config.yml b/playbooks/config.yml index b6f868a..0738e28 100644 --- a/playbooks/config.yml +++ b/playbooks/config.yml @@ -39,8 +39,6 @@ changed_when: false - name: Deploy MongDB config replicaset - when: mongodb_shard_clusters is defined - run_once: true vars: ansible_python_interpreter: "{{ _virtualenv_tmpdir.path }}/venv/bin/python" block: diff --git a/playbooks/mongos.yml b/playbooks/mongos.yml index 411cc7e..f4d3195 100644 --- a/playbooks/mongos.yml +++ b/playbooks/mongos.yml @@ -37,8 +37,6 @@ changed_when: false - name: Deploy Mongos services - when: mongodb_shard_clusters is defined - run_once: true vars: ansible_python_interpreter: "{{ _virtualenv_tmpdir.path }}/venv/bin/python" block: diff --git a/playbooks/restart.yml b/playbooks/restart.yml index a1b3237..f106faf 100644 --- a/playbooks/restart.yml +++ b/playbooks/restart.yml @@ -6,19 +6,46 @@ vars_files: - main.yml tasks: - - name: Include Mongos service tasks - ansible.builtin.include_role: - name: nephelaiio.mongodb.mongodb - tasks_from: service + - name: Create virtualenv + ansible.builtin.tempfile: + state: directory + prefix: .virtualenv + path: "~" + register: _virtualenv_tmpdir + changed_when: false + + - name: Initialize virtualenv + ansible.builtin.pip: + name: + - pymongo + - python-gnupg + virtualenv: "{{ _virtualenv_tmpdir.path }}/venv" + changed_when: false + + - name: Deploy MongDB config replicaset vars: - mongos_service_state: restarted + ansible_python_interpreter: "{{ _virtualenv_tmpdir.path }}/venv/bin/python" + block: + - name: Include Mongos service tasks + ansible.builtin.include_role: + name: nephelaiio.mongodb.mongodb + tasks_from: service + vars: + mongos_service_state: restarted + + - name: Wait for replica set to stabilize + community.mongodb.mongodb_status: + replica_set: "{{ mongos_replicaset_config_name | default('config') }}" + validate: minimal + poll: "{{ _mongodb_reconfig_poll }}" + interval: "{{ _mongodb_reconfig_interval }}" - - name: Wait for replica set to stabilize - community.mongodb.mongodb_status: - replica_set: "{{ mongos_replicaset_config_name | default('config') }}" - validate: minimal - poll: "{{ _mongodb_reconfig_poll }}" - interval: "{{ _mongodb_reconfig_interval }}" + always: + - name: Destroy virtualenv + ansible.builtin.file: + path: "{{ _virtualenv_tmpdir.path }}" + state: absent + changed_when: false - name: Restart shard1 services @@ -28,19 +55,46 @@ vars_files: - main.yml tasks: - - name: Include Mongos service tasks - ansible.builtin.include_role: - name: nephelaiio.mongodb.mongodb - tasks_from: service + - name: Create virtualenv + ansible.builtin.tempfile: + state: directory + prefix: .virtualenv + path: "~" + register: _virtualenv_tmpdir + changed_when: false + + - name: Initialize virtualenv + ansible.builtin.pip: + name: + - pymongo + - python-gnupg + virtualenv: "{{ _virtualenv_tmpdir.path }}/venv" + changed_when: false + + - name: Deploy MongDB config replicaset vars: - mongos_service_state: restarted + ansible_python_interpreter: "{{ _virtualenv_tmpdir.path }}/venv/bin/python" + block: + - name: Include Mongos service tasks + ansible.builtin.include_role: + name: nephelaiio.mongodb.mongodb + tasks_from: service + vars: + mongos_service_state: restarted - - name: Wait for replica set to stabilize - community.mongodb.mongodb_status: - replica_set: "{{ mongos_replicaset_shard1_name | default('shard1') }}" - validate: minimal - poll: "{{ _mongodb_reconfig_poll }}" - interval: "{{ _mongodb_reconfig_interval }}" + - name: Wait for replica set to stabilize + community.mongodb.mongodb_status: + replica_set: "{{ mongos_replicaset_shard1_name | default('shard1') }}" + validate: minimal + poll: "{{ _mongodb_reconfig_poll }}" + interval: "{{ _mongodb_reconfig_interval }}" + + always: + - name: Destroy virtualenv + ansible.builtin.file: + path: "{{ _virtualenv_tmpdir.path }}" + state: absent + changed_when: false - name: Restart Mongos services @@ -50,17 +104,44 @@ vars_files: - main.yml tasks: - - name: Include Mongos service tasks - ansible.builtin.include_role: - name: nephelaiio.mongodb.mongos - tasks_from: service - vars: - mongos_service_state: restarted - - - name: Check Mongos cluster status - community.mongodb.mongodb_shell: - login_database: "admin" - eval: "sh.status()" - retries: "{{ _mongodb_reconfig_poll }}" - delay: "{{ _mongodb_reconfig_interval }}" + - name: Create virtualenv + ansible.builtin.tempfile: + state: directory + prefix: .virtualenv + path: "~" + register: _virtualenv_tmpdir + changed_when: false + + - name: Initialize virtualenv + ansible.builtin.pip: + name: + - pymongo + - python-gnupg + virtualenv: "{{ _virtualenv_tmpdir.path }}/venv" changed_when: false + + - name: Deploy MongDB config replicaset + vars: + ansible_python_interpreter: "{{ _virtualenv_tmpdir.path }}/venv/bin/python" + block: + - name: Include Mongos service tasks + ansible.builtin.include_role: + name: nephelaiio.mongodb.mongos + tasks_from: service + vars: + mongos_service_state: restarted + + - name: Check Mongos cluster status + community.mongodb.mongodb_shell: + login_database: "admin" + eval: "sh.status()" + retries: "{{ _mongodb_reconfig_poll }}" + delay: "{{ _mongodb_reconfig_interval }}" + changed_when: false + + always: + - name: Destroy virtualenv + ansible.builtin.file: + path: "{{ _virtualenv_tmpdir.path }}" + state: absent + changed_when: false diff --git a/playbooks/shard.yml b/playbooks/shard.yml index 00b2759..fdf2fd7 100644 --- a/playbooks/shard.yml +++ b/playbooks/shard.yml @@ -39,8 +39,6 @@ changed_when: false - name: Deploy MongDB config replicaset - when: mongodb_shard_clusters is defined - run_once: true vars: ansible_python_interpreter: "{{ _virtualenv_tmpdir.path }}/venv/bin/python" block: diff --git a/playbooks/update.yml b/playbooks/update.yml index 8c8e5db..dbb6c6f 100644 --- a/playbooks/update.yml +++ b/playbooks/update.yml @@ -11,20 +11,47 @@ roles: - nephelaiio.mongodb.update tasks: - - name: Include Mongos service tasks - ansible.builtin.include_role: - name: nephelaiio.mongodb.mongodb - tasks_from: service + - name: Create virtualenv + ansible.builtin.tempfile: + state: directory + prefix: .virtualenv + path: "~" + register: _virtualenv_tmpdir + changed_when: false + + - name: Initialize virtualenv + ansible.builtin.pip: + name: + - pymongo + - python-gnupg + virtualenv: "{{ _virtualenv_tmpdir.path }}/venv" + changed_when: false + + - name: Restart Mongos services + vars: + ansible_python_interpreter: "{{ _virtualenv_tmpdir.path }}/venv/bin/python" + block: + - name: Include Mongos service tasks + ansible.builtin.include_role: + name: nephelaiio.mongodb.mongodb + tasks_from: service - - name: Reboot node - ansible.builtin.reboot: + - name: Reboot node + ansible.builtin.reboot: - - name: Wait for replica set to stabilize - community.mongodb.mongodb_status: - replica_set: "{{ mongos_replicaset_config_name | default('config') }}" - validate: minimal - poll: "{{ _mongodb_reconfig_poll }}" - interval: "{{ _mongodb_reconfig_interval }}" + - name: Wait for replica set to stabilize + community.mongodb.mongodb_status: + replica_set: "{{ mongos_replicaset_config_name | default('config') }}" + validate: minimal + poll: "{{ _mongodb_reconfig_poll }}" + interval: "{{ _mongodb_reconfig_interval }}" + + always: + - name: Destroy virtualenv + ansible.builtin.file: + path: "{{ _virtualenv_tmpdir.path }}" + state: absent + changed_when: false - name: Update shard1 nodes @@ -39,20 +66,47 @@ roles: - nephelaiio.mongodb.update tasks: - - name: Include Mongos service tasks - ansible.builtin.include_role: - name: nephelaiio.mongodb.mongodb - tasks_from: service + - name: Create virtualenv + ansible.builtin.tempfile: + state: directory + prefix: .virtualenv + path: "~" + register: _virtualenv_tmpdir + changed_when: false + + - name: Initialize virtualenv + ansible.builtin.pip: + name: + - pymongo + - python-gnupg + virtualenv: "{{ _virtualenv_tmpdir.path }}/venv" + changed_when: false - - name: Reboot node - ansible.builtin.reboot: + - name: Restart Mongos services + vars: + ansible_python_interpreter: "{{ _virtualenv_tmpdir.path }}/venv/bin/python" + block: + - name: Include Mongos service tasks + ansible.builtin.include_role: + name: nephelaiio.mongodb.mongodb + tasks_from: service - - name: Wait for replica set to stabilize - community.mongodb.mongodb_status: - replica_set: "{{ mongos_replicaset_shard1_name | default('shard1') }}" - validate: minimal - poll: "{{ _mongodb_reconfig_poll }}" - interval: "{{ _mongodb_reconfig_interval }}" + - name: Reboot node + ansible.builtin.reboot: + + - name: Wait for replica set to stabilize + community.mongodb.mongodb_status: + replica_set: "{{ mongos_replicaset_shard1_name | default('shard1') }}" + validate: minimal + poll: "{{ _mongodb_reconfig_poll }}" + interval: "{{ _mongodb_reconfig_interval }}" + + always: + - name: Destroy virtualenv + ansible.builtin.file: + path: "{{ _virtualenv_tmpdir.path }}" + state: absent + changed_when: false - name: Update Mongos nodes @@ -67,18 +121,45 @@ roles: - nephelaiio.mongodb.update tasks: - - name: Include Mongos service tasks - ansible.builtin.include_role: - name: nephelaiio.mongodb.mongos - tasks_from: service - - - name: Reboot node - ansible.builtin.reboot: - - - name: Check Mongos cluster status - community.mongodb.mongodb_shell: - login_database: "admin" - eval: "sh.status()" - retries: "{{ _mongodb_reconfig_poll }}" - delay: "{{ _mongodb_reconfig_interval }}" + - name: Create virtualenv + ansible.builtin.tempfile: + state: directory + prefix: .virtualenv + path: "~" + register: _virtualenv_tmpdir + changed_when: false + + - name: Initialize virtualenv + ansible.builtin.pip: + name: + - pymongo + - python-gnupg + virtualenv: "{{ _virtualenv_tmpdir.path }}/venv" changed_when: false + + - name: Restart Mongos services + vars: + ansible_python_interpreter: "{{ _virtualenv_tmpdir.path }}/venv/bin/python" + block: + - name: Include Mongos service tasks + ansible.builtin.include_role: + name: nephelaiio.mongodb.mongos + tasks_from: service + + - name: Reboot node + ansible.builtin.reboot: + + - name: Check Mongos cluster status + community.mongodb.mongodb_shell: + login_database: "admin" + eval: "sh.status()" + retries: "{{ _mongodb_reconfig_poll }}" + delay: "{{ _mongodb_reconfig_interval }}" + changed_when: false + + always: + - name: Destroy virtualenv + ansible.builtin.file: + path: "{{ _virtualenv_tmpdir.path }}" + state: absent + changed_when: false