service cloud.firestore { match /databases/{database}/documents { function getUser() { return get(/databases/$(database)/documents/users/$(request.auth.token.email)); }
match /users/{email} { allow get: if request.auth != null; allow read, write: if getUser().data.role == 'admin'; }
match /journals/{journal} { allow read: if getUser().data.role in ['viewer', 'admin']; allow create: if request.auth != null; }
match /summaries/{summary} { allow read: if request.auth != null; allow write: if getUser().data.role == 'admin'; } } } この設定は以下の制限・意図となっています。
$ vagrant up Bringing machine 'default' up with 'scaleway' provider... ==> default: Creating a server with the following settings... ==> default: -- Commercial Type: VC1S ==> default: -- Image: 9103368e-4fab-4243-aa8d-18121796c086 ==> default: -- Name: scw-****** ==> default: Starting the server... ==> default: Waiting for server to become "ready"... ==> default: Waiting for SSH to become available... 2017年 9月29日 金曜日 13時22分53秒 JST インスタンスが起動するのに2分半。
$ vagrant up Bringing machine 'default' up with 'scaleway' provider... ==> default: Creating a server with the following settings... ==> default: -- Commercial Type: VC1S ==> default: -- Image: 9103368e-4fab-4243-aa8d-18121796c086 ==> default: -- Name: scw-****** ==> default: Starting the server... ==> default: Waiting for server to become "ready"... ==> default: Waiting for SSH to become available... ==> default: Machine is booted and ready for use! ==> default: [vagrant-hostsupdater] Checking for host entries ==> default: Rsyncing folder: /Users/murave/scaleway/centos7base/ => /vagrant ==> default: Running provisioner: ansible... default: Running ansible-playbook...
PLAY [all] *********************************************************************
11 package(s) needed for security, out of 171 available
glibc.x86_64 2.17-196.el7 base glibc-common.x86_64 2.17-196.el7 base libtirpc.x86_64 0.2.4-0.10.el7 base nss.x86_64 3.28.4-11.el7_4 updates nss-sysinit.x86_64 3.28.4-11.el7_4 updates nss-tools.x86_64 3.28.4-11.el7_4 updates nss-util.x86_64 3.28.4-3.el7 base policycoreutils.x86_64 2.5-17.1.el7 base policycoreutils-python.x86_64 2.5-17.1.el7 base python-perf.x86_64 3.10.0-693.2.2.el7 updates rpcbind.x86_64 0.2.0-42.el7 base
$ vagrant up Bringing machine 'default' up with 'scaleway' provider... ==> default: Creating a server with the following settings... ==> default: -- Commercial Type: VC1S ==> default: -- Image: 9103368e-4fab-4243-aa8d-18121796c086 ==> default: -- Name: hugahoge ==> default: Starting the server... ==> default: Waiting for server to become "ready"... ==> default: Waiting for SSH to become available... ==> default: Machine is booted and ready for use! ==> default: [vagrant-hostsupdater] Checking for host entries ==> default: Rsyncing folder: /Users/murave/scaleway/vagrant_only/ => /vagrant 稼働状況
サーバー
vagrant ssh
起動したサーバーインスタンスにsshで接続する。
vagrant ssh-config
ssh接続用情報を表示(IPアドレスの確認等可能)。
$ vagrant ssh-config Host default HostName 192.0.2.1 User root Port 22 UserKnownHostsFile /dev/null StrictHostKeyChecking no PasswordAuthentication no IdentityFile /Users/murave/.ssh/id_rsa IdentitiesOnly yes LogLevel FATAL ※ HostNameはサンプル用IPに書き換えてます。
vagrant halt
サーバーインスタンス停止。
$ vagrant halt ==> default: Stopping the server... ==> default: [vagrant-hostsupdater] Removing hosts 稼働状況
$ vagrant destroy default: Are you sure you want to destroy the 'default' VM? [y/N] y ==> default: Destroying the server... ==> default: [vagrant-hostsupdater] Removing hosts 稼働状況
(haltせず)動作中にdestroyし「default: Are you sure you want to destroy the ‘default’ VM? [y/N]」で yとした場合はVolumeも削除されるので、インスタンスを使い捨てする場合にはhaltしないでdestroyしたほうが良いです。
Docker for Mac vs. Docker Toolbox を読みますと、Docker for Mac を手元で使う分には Docker Machine を意識する必要すらなくなっているようですが、docker-machineコマンドも含まれてはいたので調べていたらそういうことになっていたのでした。
$ docker-machine create \ -d openstack \ --openstack-flavor-name g-1gb \ --openstack-image-name vmi-ubuntu-14.04-amd64 \ --openstack-sec-groups "default,gncs-ipv4-all" \ conoha-docker-host Running pre-create checks... Creating machine... (conoha-docker-host) Creating machine... Waiting for machine to be running, this may take a few minutes... Detecting operating system of created instance... Waiting for SSH to be available... Detecting the provisioner... Provisioning with ubuntu(upstart)... Error creating machine: Error running provisioning: Something went wrong running an SSH command! command : DEBIAN_FRONTEND=noninteractive sudo -E apt-get install -y -o Dpkg::Options::="--force-confnew" curl err : exit status 100 output : E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
残念、provisioningでエラー発生です。調べた所 Digital Ocean でも似た状況が発生しているようです。
$ docker-machine create \ -d openstack \ --openstack-flavor-name g-1gb \ --openstack-image-name vmi-ubuntu-16.04-amd64 \ --openstack-sec-groups "default,gncs-ipv4-all" \ conoha-docker-host Running pre-create checks... Creating machine... (conoha-docker-host) Creating machine... Waiting for machine to be running, this may take a few minutes... Detecting operating system of created instance... Waiting for SSH to be available... Detecting the provisioner... Provisioning with ubuntu(systemd)... Installing Docker... Copying certs to the local machine directory... Copying certs to the remote machine... Setting Docker configuration on the remote daemon... Checking connection to Docker... Docker is up and running! To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env conoha-docker-host