4
4

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 5 years have passed since last update.

ベストプラクティスに習ってAnsibleのPlaybookの構成を変更 for mac

Last updated at Posted at 2015-10-09

前々回書いたAnbileのPlaybookベストプラクティスに習って、
再構成した。
昔作ったsetup.ymlをroleに分割し、commonに共通系のtaskを持ってみた。

Role

Roleは各機能ごとにわけて作るのがいいらしい。たとえば、macの初期設定とかrbenvの設定、
calabash-iosの設定とか、fastlaneの設定とかそういう単位でだ。
ベストプラクティスに習うと、default、files、handlers、meta、tasks、templates、varsの構成で、特殊なことをしなくても基本的にはそれぞれのディレクトリのmain.ymlを読みに行くようだ。

具体的な構成

共通系のtaskは呼び出しタイミングは様々なので、別途rootpathにbaseSetting.ymlをおいて、commonのそれぞれのpathを変数定義しやることで、各role内から呼び出せるようにしている。

tree
├── README.md
├── baseSetting.yml
├── common.yml
├── hosts.list
├── macSetting.yml
├── main.yml
├── rbenv.yml
├── roles
│   ├── common
│   │   ├── defaults
│   │   │   └── main.yml
│   │   ├── files
│   │   │   └── main.yml
│   │   ├── handlers
│   │   │   ├── fontCache.yml
│   │   │   └── main.yml
│   │   ├── meta
│   │   │   └── main.yml
│   │   ├── tasks
│   │   │   ├── brewPakcagesInstaller.yml
│   │   │   ├── caskPackagesInstaller.yml
│   │   │   ├── gemPackagesInstaller.yml
│   │   │   ├── homebrewDepends.yml
│   │   │   └── main.yml
│   │   └── vars
│   │       └── main.yml
│   ├── fastlane
│   │   └── vars
│   │       └── gem_packages
│   ├── mac_setting
│   │   ├── defaults
│   │   │   └── main.yml
│   │   ├── files
│   │   │   └── main.yml
│   │   ├── handlers
│   │   │   ├── fontCache.yml
│   │   │   └── main.yml
│   │   ├── meta
│   │   │   └── main.yml
│   │   ├── tasks
│   │   │   └── main.yml
│   │   ├── templates
│   │   │   └── main.yml
│   │   └── vars
│   │       ├── brewCaskPackages.yml
│   │       ├── brewPackages.yml
│   │       ├── brewTapList.yml
│   │       ├── gemPackages.yml
│   │       └── main.yml
│   ├── rbenv
│   │   ├── defaults
│   │   │   └── main.yml
│   │   ├── files
│   │   │   └── main.yml
│   │   ├── handlers
│   │   │   └── main.yml
│   │   ├── meta
│   │   │   └── main.yml
│   │   ├── tasks
│   │   │   ├── main.yml
│   │   │   └── setBashProfile.yml
│   │   ├── templates
│   │   │   └── main.yml
│   │   └── vars
│   │       ├── brewTapList.yml
│   │       ├── devEnvBrewPackages.yml
│   │       ├── main.yml
│   │       └── rbEnvBrewPackages.yml
│   └── sample
│       ├── defaults
│       │   └── main.yml
│       ├── files
│       │   └── main.yml
│       ├── handlers
│       │   └── main.yml
│       ├── meta
│       │   └── main.yml
│       ├── tasks
│       │   └── main.yml
│       ├── templates
│       │   └── main.yml
│       └── vars
│           └── main.yml
├── setup.yml
└── site.yml

ソースはgithubにおいてるので参考までに。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?