blob: e85563fd4534e79373ba16b1a2a7f5382acb01ca [file] [log] [blame]
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
# generate erlang cookie for CouchDB
- name: "generate erlang cookie"
local_action: command openssl rand -base64 32op
register: random_stdout
run_once: true
when: erlang_cookie is not defined
- set_fact:
erlang_cookie: "{{ random_stdout.stdout }}"
when: erlang_cookie is not defined
- name: "ensure config root dir exists"
file:
path: "{{ config_root_dir }}"
state: directory
# when enable uid namespace mode, couchdb container doesn't have permission to change the owner of files which mounted
# from host, so the container will be failed to start. Use a temporary container here to create the file erlang.cookie
# with the correct user 'couchdb' as its owner
- name: "create the erlang cookie file on remote"
vars:
couchdb_image: "{{ couchdb.docker_image | default('apache/couchdb:' ~ couchdb.version ) }}"
command: "docker run --rm -v /tmp:/tmp -u couchdb {{ couchdb_image }} sh -c 'echo {{ erlang_cookie }} >> /tmp/erlang.cookie'"
become: true
- name: "move erlang.cookie from /tmp to {{ config_root_dir }}"
shell: "chmod 400 /tmp/erlang.cookie && mv /tmp/erlang.cookie {{ config_root_dir }}/erlang.cookie"
args:
warn: false
become: true