LoginSignup
3
3

More than 5 years have passed since last update.

GCE 向け Ansible の dynamic inventory(gcloudコマンド版)

Posted at

GCP のホストを Ansible の dynamic inventory で引くの、定番は gce.py を使って設定するんですが、普段 gcloud コマンドの権限使って作業してるのにこのためだけに別途 p12 持ってきてとか面倒。

なので gcloud コマンドを使って引っ張ってくるものを前に書きました。
https://gist.github.com/holysugar/190cbbe99658805f1a53

これを hosts/gce.rb あたりに置いて、 hosts/production とかに

#!/usr/bin/env ruby

require_relative 'gce'
puts GCE.new('ourproductionid', 'production').result

みたいに書いて ansible-playbook -i hosts/production .... とすれば environment=production タグが付いたホストに対して実行できるはずです。

3
3
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
3
3