diff --git a/bin/tm_deploy b/bin/tm_deploy index 82060f8..ef6f903 100755 --- a/bin/tm_deploy +++ b/bin/tm_deploy @@ -81,37 +81,41 @@ def _get_group_variables(vars_dir): variables = collections.OrderedDict() if os.path.exists(vars_dir): group_dirs = os.listdir(vars_dir) - for group in group_dirs: - filename = os.path.abspath( - os.path.join(vars_dir, group, 'vars.yml') - ) - with open(filename) as f: - for line in f.readlines(): - var_mapping = yaml.load(line) - if var_mapping is None: - continue - for k, v in var_mapping.items(): - if type(v) in {list, dict}: - raise TypeError( - 'Only simply key=value variables are supported.' - ) - variables[k] = v + else: + group_dirs = [] + for group in group_dirs: + filename = os.path.abspath( + os.path.join(vars_dir, group, 'vars.yml') + ) + with open(filename) as f: + for line in f.readlines(): + var_mapping = yaml.load(line) + if var_mapping is None: + continue + for k, v in var_mapping.items(): + if type(v) in {list, dict}: + raise TypeError( + 'Only simply key=value variables are supported.' + ) + variables[k] = v return variables def _build_ansible_container_command(verbosity, action_command): playbooks_dir = _get_playbooks_dir('tissuemaps') roles_dir, vars_dir = _get_roles_and_variables_directories('tissuemaps') - project_dir = os.path.join( + project_dir = os.path.abspath(os.path.join( playbooks_dir, '../../container/projects/tissuemaps' - ) - cmd = ['ansible-container', '--project', os.path.abspath(project_dir)] + )) + cmd = ['ansible-container', '--project-path', project_dir] if os.path.exists(vars_dir): group_dirs = os.listdir(vars_dir) - # NOTE: Ansible variables {{ }} declared in files are not expanded! - for group in group_dirs: - filename = os.path.abspath(os.path.join(vars_dir, group, 'vars.yml')) - cmd.extend(['--var-file', filename]) + else: + group_dirs = [] + # NOTE: Ansible variables {{ }} declared in files are not expanded! + for group in group_dirs: + filename = os.path.abspath(os.path.join(vars_dir, group, 'vars.yml')) + cmd.extend(['--var-file', filename]) if verbosity > 3: cmd.append('--debug') cmd.extend(action_command) @@ -140,8 +144,10 @@ def _build_ansible_vm_command(verbosity, playbook, variables=dict()): return cmd -def _run_command(command, environment): - process = subprocess.Popen(command, stdout=subprocess.PIPE, env=environment) +def _run_command(command, environment, working_dir=None): + process = subprocess.Popen( + command, stdout=subprocess.PIPE, env=environment, cwd=working_dir + ) while True: line = process.stdout.readline() if line != b'': @@ -155,9 +161,13 @@ def _run_container_commands(commands): env = dict(os.environ) env['DOCKER_CLIENT_TIMEOUT'] = str(600) env['COMPOSE_HTTP_TIMEOUT'] = str(600) + # FIXME: Workaround bug in ansible-container 0.9.1 + working_dir = os.path.abspath(os.path.join( + _get_playbooks_dir('tissuemaps'), '../../container/projects/tissuemaps' + )) for cmd in commands: logger.debug('command: %s', ' '.join(cmd)) - _run_command(cmd, env) + _run_command(cmd, env, working_dir) def _run_vm_commands(commands, setup_file): @@ -240,10 +250,12 @@ def show_vm_setup(args): def build_container(args): logger.info('build container images') roles_dir, vars_dir = _get_roles_and_variables_directories('tissuemaps') - cmd = [ - 'build', '--from-scratch', - '--roles-path', os.path.abspath(roles_dir) - ] + cmd = ['build', '--roles-path', os.path.abspath(roles_dir)] + if args.no_cache: + cmd.append('--no-cache') + # Workaround ansible-container issue that doesn't install dependencies + # correctly in conductor container. + # cmd.append('--use-local-python') # The following options are parsed to the "ansible-playbooks" command. cmd.append('--') verbosity = args.verbosity @@ -372,6 +384,10 @@ if __name__ == '__main__': description='Build container images.' ) container_build_subparser.set_defaults(function='build_container') + container_build_subparser.add_argument( + '--from-scratch', dest='no_cache', action='store_true', + help='rerun the entire build process without using cache' + ) container_start_subparser = container_subparsers.add_parser( 'start', help='create and run containers', diff --git a/setup.py b/setup.py index 0f17e9c..bf2a665 100755 --- a/setup.py +++ b/setup.py @@ -106,9 +106,10 @@ def get_version(): include_package_data=True, install_requires=[ 'ansible>=2.2.1', - 'ansible-container>=0.3.0,<=0.4', + 'ansible-container>=0.9.0', 'apache-libcloud>=1.3.0', 'boto3>=1.4.1', + 'docker>=2.2', 'docker-py>=1.10.6', 'PyYAML>=3.11', 'psycopg2>=2.6.1', @@ -116,4 +117,3 @@ def get_version(): 'whichcraft>=0.4.0' ] ) - diff --git a/tmdeploy/share/container/images/base/Dockerfile b/tmdeploy/share/container/images/base/Dockerfile index 29eeae2..353b70a 100644 --- a/tmdeploy/share/container/images/base/Dockerfile +++ b/tmdeploy/share/container/images/base/Dockerfile @@ -3,6 +3,7 @@ FROM ubuntu:xenial RUN apt-get update && apt-get -y install \ aptitude \ build-essential \ + sudo \ man \ git \ libssl-dev \ diff --git a/tmdeploy/share/container/images/base/README.md b/tmdeploy/share/container/images/base/README.md index 868a079..d88d3d2 100644 --- a/tmdeploy/share/container/images/base/README.md +++ b/tmdeploy/share/container/images/base/README.md @@ -3,6 +3,5 @@ TissueMAPS base image Extends the official "ubuntu:xenial" image with - Essential apt packages (built-essential, wget, ...) -- Python 2.7.12 +- Python 2.7 - Essential Python packages (pip, setuptools, ...) -- "tissuemaps" user with sudo permissions diff --git a/tmdeploy/share/container/projects/tissuemaps/ansible-requirements.txt b/tmdeploy/share/container/projects/tissuemaps/ansible-requirements.txt new file mode 100644 index 0000000..73e4565 --- /dev/null +++ b/tmdeploy/share/container/projects/tissuemaps/ansible-requirements.txt @@ -0,0 +1,3 @@ +# These are the python requirements for your Ansible Container builder. +# You do not need to include Ansible itself in this file. +psycopg2==2.7.1 diff --git a/tmdeploy/share/container/projects/tissuemaps/ansible/ansible.cfg b/tmdeploy/share/container/projects/tissuemaps/ansible.cfg similarity index 94% rename from tmdeploy/share/container/projects/tissuemaps/ansible/ansible.cfg rename to tmdeploy/share/container/projects/tissuemaps/ansible.cfg index 5691117..bbbc242 100644 --- a/tmdeploy/share/container/projects/tissuemaps/ansible/ansible.cfg +++ b/tmdeploy/share/container/projects/tissuemaps/ansible.cfg @@ -16,3 +16,4 @@ [defaults] ansible_user = root become_method = dockerexec +roles_path = ../../../playbooks/tissuemaps/roles diff --git a/tmdeploy/share/container/projects/tissuemaps/ansible/main.yml b/tmdeploy/share/container/projects/tissuemaps/ansible/main.yml deleted file mode 100644 index 99b6e2e..0000000 --- a/tmdeploy/share/container/projects/tissuemaps/ansible/main.yml +++ /dev/null @@ -1,93 +0,0 @@ -# TmDeploy - Automated setup and deployment of TissueMAPS in the cloud. -# Copyright (C) 2016 Markus D. Herrmann, University of Zurich - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . ---- -- name: Setup web container - hosts: web - vars: - web_user: tissuemaps - web_port: 8002 - app_host: app - app_port: 5002 - public_host_name: web - roles: - - web-server - -- name: Setup app container - hosts: app - vars: - app_host: app - app_port: 5002 - uwsgi_processes: 1 - roles: - - app-server - -- name: Setup database worker container - hosts: db_worker - roles: - - database-server-worker - -- name: Setup database master container - hosts: db_master - roles: - - database-server-master - -- name: Start database server on workers - hosts: db_worker - remote_user: postgres - tasks: - - name: Start database cluster - command: /usr/lib/postgresql/9.6/bin/pg_ctl start -o "-p 9700" -D /storage/database/worker - -- name: Stop database server on master - hosts: db_master - remote_user: postgres - tasks: - - name: Start database cluster - command: /usr/lib/postgresql/9.6/bin/pg_ctl start -o "-p 5432" -D /storage/database/master - -- name: Configure app container as database client - hosts: app - vars: - db_host_master: db_master - db_hosts_workers: - - db_worker - roles: - - database-client - -# It is important for container to shut down the server in a clean mode, i.e. -# wait for all backup processes to finish. -# Otherwise, there will be problems when running the container afterwards. -- name: Stop database server on workers - hosts: db_worker - remote_user: postgres - tasks: - - name: Stop database cluster - command: /usr/lib/postgresql/9.6/bin/pg_ctl stop -m smart -o "-p 9700" -D /storage/database/worker - -- name: Stop database server on master - hosts: db_master - remote_user: postgres - tasks: - - name: Stop database cluster - command: /usr/lib/postgresql/9.6/bin/pg_ctl stop -m smart -o "-p 5432" -D /storage/database/master - -- name: Clean up - hosts: all - tasks: - - name: Clean apt-get - raw: apt-get clean - - name: Remove apt package files - raw: rm -rf /var/lib/apt/lists/* diff --git a/tmdeploy/share/container/projects/tissuemaps/ansible/requirements.txt b/tmdeploy/share/container/projects/tissuemaps/ansible/requirements.txt deleted file mode 100644 index e69de29..0000000 diff --git a/tmdeploy/share/container/projects/tissuemaps/ansible/requirements.yml b/tmdeploy/share/container/projects/tissuemaps/ansible/requirements.yml deleted file mode 100644 index e69de29..0000000 diff --git a/tmdeploy/share/container/projects/tissuemaps/ansible/container.yml b/tmdeploy/share/container/projects/tissuemaps/container.yml similarity index 64% rename from tmdeploy/share/container/projects/tissuemaps/ansible/container.yml rename to tmdeploy/share/container/projects/tissuemaps/container.yml index 3aa9f1c..511e275 100644 --- a/tmdeploy/share/container/projects/tissuemaps/ansible/container.yml +++ b/tmdeploy/share/container/projects/tissuemaps/container.yml @@ -16,14 +16,51 @@ --- version: '2' -# NOTE: ansible-container doesn't support the "network" directive yet and the -# "volume" directive also has issues. Therefore, we handle this in the +# NOTE: ansible-container doesn't support the "networks" directive yet and the +# "volumes" directive also has issues. Therefore, we handle this in the # docker-compose.yml file. +settings: + + conductor_base: tissuemaps/base + project_name: tissuemaps + services: + db_master: + from: tissuemaps/base + user: postgres + expose: + - '5043' + depends_on: + - db_worker + command: + - 'dumb-init' + - '/usr/lib/postgresql/9.6/bin/postgres' + - '-D' + - '/storage/postgresql/data/9.6/master' + - '-c' + - 'config_file=/etc/postgresql/9.6/master/postgresql.conf' + roles: + - role: database-server-master + + db_worker: + from: tissuemaps/base + user: postgres + expose: + - '9700' + command: + - 'dumb-init' + - '/usr/lib/postgresql/9.6/bin/postgres' + - '-D' + - '/storage/postgresql/data/9.6/worker' + - '-c' + - 'config_file=/etc/postgresql/9.6/worker/postgresql.conf' + roles: + - role: database-server-worker + web: - image: tissuemaps/base + from: tissuemaps/base user: tissuemaps working_dir: /home/tissuemaps ports: @@ -41,9 +78,15 @@ services: - '/usr/bin/gulp' - '--gulpfile' - '/home/tissuemaps/tmui/src/gulpfile.js' + roles: + - role: web-server + web_user: tissuemaps + web_port: 8002 + app_host: app + app_port: 5002 app: - image: tissuemaps/base + from: tissuemaps/base user: tissuemaps working_dir: /home/tissuemaps expose: @@ -58,35 +101,12 @@ services: - 'dumb-init' - '/home/tissuemaps/.tmaps/tm_server.sh' - '-vv' - - db_master: - image: tissuemaps/base - user: postgres - expose: - - '5432' - depends_on: - - db_worker - command: - - 'dumb-init' - - '/usr/lib/postgresql/9.6/bin/postgres' - - '-p' - - '5432' - - '-D' - - '/storage/database/master' - - '-c' - - 'config_file=/storage/database/master/postgresql.conf' - - db_worker: - image: tissuemaps/base - user: postgres - expose: - - '9700' - command: - - 'dumb-init' - - '/usr/lib/postgresql/9.6/bin/postgres' - - '-p' - - '9700' - - '-D' - - '/storage/database/worker' - - '-c' - - 'config_file=/storage/database/worker/postgresql.conf' + roles: + - role: app-server + app_host: app + app_port: 5002 + uwsgi_processes: 1 + - role: database-client + db_host_master: db_master + db_hosts_workers: + - db_worker diff --git a/tmdeploy/share/container/projects/tissuemaps/meta/main.yml b/tmdeploy/share/container/projects/tissuemaps/meta/main.yml deleted file mode 100644 index e69de29..0000000 diff --git a/tmdeploy/share/playbooks/tissuemaps/roles/app-server/meta/main.yml b/tmdeploy/share/playbooks/tissuemaps/roles/app-server/meta/main.yml index 69da26a..e9ca62b 100644 --- a/tmdeploy/share/playbooks/tissuemaps/roles/app-server/meta/main.yml +++ b/tmdeploy/share/playbooks/tissuemaps/roles/app-server/meta/main.yml @@ -15,4 +15,4 @@ # along with this program. If not, see . --- dependencies: - - compute + - role: compute diff --git a/tmdeploy/share/playbooks/tissuemaps/roles/app-server/tasks/scripts.yml b/tmdeploy/share/playbooks/tissuemaps/roles/app-server/tasks/scripts.yml index 00c01fb..24a6ec6 100644 --- a/tmdeploy/share/playbooks/tissuemaps/roles/app-server/tasks/scripts.yml +++ b/tmdeploy/share/playbooks/tissuemaps/roles/app-server/tasks/scripts.yml @@ -24,7 +24,7 @@ with_items: - start_server.sh - stop_server.sh - when: ansible_env.ANSIBLE_CONTAINER is undefined + when: ansible_connection != 'docker' tags: - web diff --git a/tmdeploy/share/playbooks/tissuemaps/roles/app-server/tasks/ssh_keys.yml b/tmdeploy/share/playbooks/tissuemaps/roles/app-server/tasks/ssh_keys.yml index d3bb64f..bfac645 100644 --- a/tmdeploy/share/playbooks/tissuemaps/roles/app-server/tasks/ssh_keys.yml +++ b/tmdeploy/share/playbooks/tissuemaps/roles/app-server/tasks/ssh_keys.yml @@ -20,7 +20,7 @@ user: root key: https://github.com/{{ item }}.keys with_items: "{{ tm_admins }}" - when: ansible_env.ANSIBLE_CONTAINER is undefined + when: ansible_connection != 'docker' tags: - ssh @@ -29,7 +29,7 @@ user: "{{ tm_user }}" key: https://github.com/{{ item }}.keys with_items: "{{ tm_admins }}" - when: ansible_env.ANSIBLE_CONTAINER is undefined + when: ansible_connection != 'docker' tags: - ssh diff --git a/tmdeploy/share/playbooks/tissuemaps/roles/app-server/tasks/tissuemaps.yml b/tmdeploy/share/playbooks/tissuemaps/roles/app-server/tasks/tissuemaps.yml index c699a03..52c3b7a 100644 --- a/tmdeploy/share/playbooks/tissuemaps/roles/app-server/tasks/tissuemaps.yml +++ b/tmdeploy/share/playbooks/tissuemaps/roles/app-server/tasks/tissuemaps.yml @@ -77,7 +77,7 @@ owner: "{{ tm_user }}" group: "{{ tm_group }}" mode: 0700 - when: ansible_env.ANSIBLE_CONTAINER is defined + when: ansible_connection == 'docker' tags: - tissuemaps diff --git a/tmdeploy/share/playbooks/tissuemaps/roles/app-server/tasks/uwsgi.yml b/tmdeploy/share/playbooks/tissuemaps/roles/app-server/tasks/uwsgi.yml index 634d521..4825867 100644 --- a/tmdeploy/share/playbooks/tissuemaps/roles/app-server/tasks/uwsgi.yml +++ b/tmdeploy/share/playbooks/tissuemaps/roles/app-server/tasks/uwsgi.yml @@ -123,7 +123,7 @@ owner: "{{ tm_user }}" group: "{{ tm_group }}" mode: 0700 - when: ansible_env.ANSIBLE_CONTAINER is defined + when: ansible_connection == 'docker' tags: - app-server - uwsgi @@ -135,7 +135,7 @@ owner: "{{ tm_user }}" group: "{{ tm_group }}" mode: 0700 - when: ansible_env.ANSIBLE_CONTAINER is undefined + when: ansible_connection != 'docker' tags: - app-server - uwsgi @@ -147,7 +147,7 @@ owner: "{{ tm_user }}" group: "{{ tm_group }}" when: - - ansible_env.ANSIBLE_CONTAINER is undefined + - ansible_connection != 'docker' tags: - app-server - uwsgi diff --git a/tmdeploy/share/playbooks/tissuemaps/roles/app-server/templates/tmpfiles.d.uwsgi.conf.j2 b/tmdeploy/share/playbooks/tissuemaps/roles/app-server/templates/tmpfiles.d.uwsgi.conf.j2 index c7994fc..51f9780 100644 --- a/tmdeploy/share/playbooks/tissuemaps/roles/app-server/templates/tmpfiles.d.uwsgi.conf.j2 +++ b/tmdeploy/share/playbooks/tissuemaps/roles/app-server/templates/tmpfiles.d.uwsgi.conf.j2 @@ -1,3 +1,3 @@ d /var/run/uwsgi 0750 {{ tm_user }} {{ web_group }} - -a+ /var/run/uwsgi - - - - u:nginx:rx -a+ /var/run/uwsgi - - - - default:u:nginx:rw +a+ /var/run/uwsgi - - - - u:{{ web_user }}:rx +a+ /var/run/uwsgi - - - - default:u:{{ web_user }}:rw diff --git a/tmdeploy/share/container/projects/tissuemaps/docker-compose.local_override.yml b/tmdeploy/share/playbooks/tissuemaps/roles/cleanup/tasks/clean-Debian.yml similarity index 78% rename from tmdeploy/share/container/projects/tissuemaps/docker-compose.local_override.yml rename to tmdeploy/share/playbooks/tissuemaps/roles/cleanup/tasks/clean-Debian.yml index 2bf042d..73c5ef1 100644 --- a/tmdeploy/share/container/projects/tissuemaps/docker-compose.local_override.yml +++ b/tmdeploy/share/playbooks/tissuemaps/roles/cleanup/tasks/clean-Debian.yml @@ -14,20 +14,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . --- -version: '3' +- name: Clean apt-get + raw: apt-get clean -services: +- name: Remove apt package files + raw: rm -rf /var/lib/apt/lists/* - web: - image: tissuemaps-web - ports: - - '8002:8002' - - app: - image: tissuemaps-app - - db_master: - image: tissuemaps-db_master - - db_worker: - image: tissuemaps-db_worker diff --git a/tmdeploy/share/playbooks/tissuemaps/roles/cleanup/tasks/clean-RedHat.yml b/tmdeploy/share/playbooks/tissuemaps/roles/cleanup/tasks/clean-RedHat.yml new file mode 100644 index 0000000..5f34229 --- /dev/null +++ b/tmdeploy/share/playbooks/tissuemaps/roles/cleanup/tasks/clean-RedHat.yml @@ -0,0 +1,21 @@ +# TmDeploy - Automated setup and deployment of TissueMAPS in the cloud. +# Copyright (C) 2016 Markus D. Herrmann, University of Zurich + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +--- +- name: Clean yum + raw: yum clean all + +- name: Remove yum package files + raw: rm -rf /var/cache/yum/* diff --git a/tmdeploy/share/playbooks/tissuemaps/roles/cleanup/tasks/main.yml b/tmdeploy/share/playbooks/tissuemaps/roles/cleanup/tasks/main.yml new file mode 100644 index 0000000..f2e1099 --- /dev/null +++ b/tmdeploy/share/playbooks/tissuemaps/roles/cleanup/tasks/main.yml @@ -0,0 +1,2 @@ +--- +- include: clean-{{ ansible_os_family }}.yml diff --git a/tmdeploy/share/playbooks/tissuemaps/roles/common/meta/main.yml b/tmdeploy/share/playbooks/tissuemaps/roles/common/meta/main.yml deleted file mode 100644 index e69de29..0000000 diff --git a/tmdeploy/share/playbooks/tissuemaps/roles/common/tasks/main.yml b/tmdeploy/share/playbooks/tissuemaps/roles/common/tasks/main.yml index e339dd6..58100f7 100644 --- a/tmdeploy/share/playbooks/tissuemaps/roles/common/tasks/main.yml +++ b/tmdeploy/share/playbooks/tissuemaps/roles/common/tasks/main.yml @@ -46,12 +46,12 @@ - include: init-{{ ansible_os_family }}.yml - include: utils-{{ ansible_os_family }}.yml - when: ansible_env.ANSIBLE_CONTAINER is undefined + when: ansible_connection != 'docker' - include: ssh.yml - when: ansible_env.ANSIBLE_CONTAINER is undefined + when: ansible_connection != 'docker' - include: collectl.yml - when: ansible_env.ANSIBLE_CONTAINER is undefined + when: ansible_connection != 'docker' - include: suexec.yml diff --git a/tmdeploy/share/playbooks/tissuemaps/roles/compute/meta/main.yml b/tmdeploy/share/playbooks/tissuemaps/roles/compute/meta/main.yml index 9315326..0224ce5 100644 --- a/tmdeploy/share/playbooks/tissuemaps/roles/compute/meta/main.yml +++ b/tmdeploy/share/playbooks/tissuemaps/roles/compute/meta/main.yml @@ -16,4 +16,4 @@ --- dependencies: - - common + - role: common diff --git a/tmdeploy/share/playbooks/tissuemaps/roles/database-client/meta/main.yml b/tmdeploy/share/playbooks/tissuemaps/roles/database-client/meta/main.yml index ddbe7a1..2442a62 100644 --- a/tmdeploy/share/playbooks/tissuemaps/roles/database-client/meta/main.yml +++ b/tmdeploy/share/playbooks/tissuemaps/roles/database-client/meta/main.yml @@ -15,4 +15,4 @@ # along with this program. If not, see . --- dependencies: - - common + - role: common diff --git a/tmdeploy/share/playbooks/tissuemaps/roles/database-server-common/meta/main.yml b/tmdeploy/share/playbooks/tissuemaps/roles/database-server-common/meta/main.yml index ddbe7a1..2442a62 100644 --- a/tmdeploy/share/playbooks/tissuemaps/roles/database-server-common/meta/main.yml +++ b/tmdeploy/share/playbooks/tissuemaps/roles/database-server-common/meta/main.yml @@ -15,4 +15,4 @@ # along with this program. If not, see . --- dependencies: - - common + - role: common diff --git a/tmdeploy/share/playbooks/tissuemaps/roles/database-server-common/tasks/configure.yml b/tmdeploy/share/playbooks/tissuemaps/roles/database-server-common/tasks/configure.yml index 15a2d3b..29e1d0c 100644 --- a/tmdeploy/share/playbooks/tissuemaps/roles/database-server-common/tasks/configure.yml +++ b/tmdeploy/share/playbooks/tissuemaps/roles/database-server-common/tasks/configure.yml @@ -100,7 +100,7 @@ line: 'host {{ db_name }} {{ db_role }} 10.0.0.0/8 trust' owner: "{{ db_user }}" group: "{{ db_group }}" - when: ansible_env.ANSIBLE_CONTAINER is defined + when: ansible_connection == 'docker' tags: - database @@ -111,7 +111,7 @@ line: 'host all {{ db_user }} 10.0.0.0/8 trust' owner: "{{ db_user }}" group: "{{ db_group }}" - when: ansible_env.ANSIBLE_CONTAINER is defined + when: ansible_connection == 'docker' tags: - database @@ -122,7 +122,7 @@ line: 'host {{ db_name }} {{ db_role }} 172.16.0.0/12 trust' owner: "{{ db_user }}" group: "{{ db_group }}" - when: ansible_env.ANSIBLE_CONTAINER is defined + when: ansible_connection == 'docker' tags: - database @@ -133,7 +133,7 @@ line: 'host all {{ db_user }} 172.16.0.0/12 trust' owner: "{{ db_user }}" group: "{{ db_group }}" - when: ansible_env.ANSIBLE_CONTAINER is defined + when: ansible_connection == 'docker' tags: - database @@ -144,7 +144,7 @@ line: 'host {{ db_name }} {{ db_role }} 192.168.0.0/16 trust' owner: "{{ db_user }}" group: "{{ db_group }}" - when: ansible_env.ANSIBLE_CONTAINER is defined + when: ansible_connection == 'docker' tags: - database @@ -155,7 +155,7 @@ line: 'host all {{ db_user }} 192.168.0.0/16 trust' owner: "{{ db_user }}" group: "{{ db_group }}" - when: ansible_env.ANSIBLE_CONTAINER is defined + when: ansible_connection == 'docker' tags: - database diff --git a/tmdeploy/share/playbooks/tissuemaps/roles/database-server-common/tasks/create_cluster.yml b/tmdeploy/share/playbooks/tissuemaps/roles/database-server-common/tasks/create_cluster.yml index e38e903..772f452 100644 --- a/tmdeploy/share/playbooks/tissuemaps/roles/database-server-common/tasks/create_cluster.yml +++ b/tmdeploy/share/playbooks/tissuemaps/roles/database-server-common/tasks/create_cluster.yml @@ -119,7 +119,7 @@ owner: "{{ tm_user }}" group: "{{ tm_group }}" when: - - ansible_env.ANSIBLE_CONTAINER is undefined + - ansible_connection != 'docker' tags: - database diff --git a/tmdeploy/share/playbooks/tissuemaps/roles/database-server-common/tasks/install-Debian.yml b/tmdeploy/share/playbooks/tissuemaps/roles/database-server-common/tasks/install-Debian.yml index a28e609..80688f9 100644 --- a/tmdeploy/share/playbooks/tissuemaps/roles/database-server-common/tasks/install-Debian.yml +++ b/tmdeploy/share/playbooks/tissuemaps/roles/database-server-common/tasks/install-Debian.yml @@ -43,7 +43,7 @@ tags: - database -- name: Install Citus PostgreSQL +- name: Install apt packages required by Citus PostgreSQL apt: state: installed name: "{{ item }}" diff --git a/tmdeploy/share/playbooks/tissuemaps/roles/database-server-master/meta/main.yml b/tmdeploy/share/playbooks/tissuemaps/roles/database-server-master/meta/main.yml index 7545cd2..1f74cfe 100644 --- a/tmdeploy/share/playbooks/tissuemaps/roles/database-server-master/meta/main.yml +++ b/tmdeploy/share/playbooks/tissuemaps/roles/database-server-master/meta/main.yml @@ -15,4 +15,4 @@ # along with this program. If not, see . --- dependencies: - - database-server-common + - role: database-server-common diff --git a/tmdeploy/share/playbooks/tissuemaps/roles/database-server-worker/meta/main.yml b/tmdeploy/share/playbooks/tissuemaps/roles/database-server-worker/meta/main.yml index 398c494..cac2427 100644 --- a/tmdeploy/share/playbooks/tissuemaps/roles/database-server-worker/meta/main.yml +++ b/tmdeploy/share/playbooks/tissuemaps/roles/database-server-worker/meta/main.yml @@ -30,4 +30,4 @@ # along with this program. If not, see . --- dependencies: - - database-server-common + - role: database-server-common diff --git a/tmdeploy/share/playbooks/tissuemaps/roles/web-server/meta/main.yml b/tmdeploy/share/playbooks/tissuemaps/roles/web-server/meta/main.yml index ddbe7a1..2442a62 100644 --- a/tmdeploy/share/playbooks/tissuemaps/roles/web-server/meta/main.yml +++ b/tmdeploy/share/playbooks/tissuemaps/roles/web-server/meta/main.yml @@ -15,4 +15,4 @@ # along with this program. If not, see . --- dependencies: - - common + - role: common diff --git a/tmdeploy/share/playbooks/tissuemaps/roles/web-server/tasks/nginx.yml b/tmdeploy/share/playbooks/tissuemaps/roles/web-server/tasks/nginx.yml index c515001..972a8cd 100644 --- a/tmdeploy/share/playbooks/tissuemaps/roles/web-server/tasks/nginx.yml +++ b/tmdeploy/share/playbooks/tissuemaps/roles/web-server/tasks/nginx.yml @@ -97,7 +97,7 @@ owner: "{{ web_user }}" group: "{{ web_group }}" mode: 0700 - when: ansible_env.ANSIBLE_CONTAINER is defined + when: ansible_connection == 'docker' tags: - web-server - nginx @@ -109,7 +109,7 @@ owner: "{{ web_user }}" group: "{{ web_group }}" mode: 0700 - when: ansible_env.ANSIBLE_CONTAINER is undefined + when: ansible_connection != 'docker' tags: - web-server - nginx @@ -121,7 +121,7 @@ owner: "{{ web_user }}" group: "{{ web_group }}" when: - - ansible_env.ANSIBLE_CONTAINER is undefined + - ansible_connection != 'docker' tags: - web-server - nginx