0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

PHP製デプロイツール Deployer v7beta を試す 接続編

Last updated at Posted at 2020-12-09

はじめに

PHP製デプロイツール Deployer v7beta を試す init編の続き

接続先の設定

  • hostnameや鍵は便宜上example.comにしているので適宜読み替え
    • 実際はEC2につないでます

ファイルツリー

/path/to/project
├─deployer
│  ├─hosts.php
│  └─hosts.yaml
└─deploy.php
deploy.php
<?php

namespace Deployer;

import('deployer/hosts.php');
import('deployer/hosts.yaml');

task('dep:pwd', function () {
    cd(get('deploy_path'));
    writeln(run('pwd'));
});
deployer/hosts.php
<?php

namespace Deployer;

host('dev1')
    ->setHostname('example.com')
    ->setRemoteUser("ec2-user")
    ->setIdentityFile("~/.ssh/example.com.pem")
    ->setDeployPath('/tmp/deployer/dev1');
deployer/hosts.yaml
hosts:
  dev_base: &dev_base
    hostname: example.com
    remote_user: ec2-user
    identity_file: ~/.ssh/example.com.pem
  dev2:
    <<: *dev_base
    deploy_path: '/tmp/deployer/dev2'
  dev3:
    <<: *dev_base
    deploy_path: '/tmp/deployer/dev3'

タスクの実行

  • 事前に接続先で対象のディレクトリは作成済み

dev1向けを実行(hostはphpに定義)

$ dep dep:pwd dev1
task dep:pwd
[dev1] /tmp/deployer/dev1

dev2向けを実行(hostはyamlに定義)

$ dep dep:pwd dev2
task dep:pwd
[dev2] /tmp/deployer/dev2

dev3向けを実行(hostはyamlに定義)

$ dep dep:pwd dev3
task dep:pwd
[dev3] /tmp/deployer/dev3

まとめ

  • ちゃんと対応していけばsshでの接続まではいけた
  • 思ったほどバージョンアップは怖くない

ぱっと思う主に変わった点

  • initでyamlとphpを選べるようになった
  • hosts周り(旧inventory)の定義をyamlで行う場合の記述方法
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?