Why not login to Qiita and try out its useful features?

We'll deliver articles that match you.

You can read useful information later.

32
32

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で複数のroleを並行開発するのにgit subtreeを使ってみた

Posted at

role毎に別のgitレポジトリだと開発時の手間が煩雑

roleを作成してAnsible Galaxyに登録するワークフロー - Qiitaでは1つ1つのroleごとにgitレポジトリを作成して、Ansible Galaxyに登録し、ansible-galaxy install でローカルに取得して利用していました。

が、それぞれのroleを開発中の場合は、修正してgitレポジトリにあげて、ansible-galaxy install--force つきで実行して更新するという手間が面倒でした。

git subtreeを使ってみたら便利でした

そこで、git subtreeを使って各role毎にgitレポジトリは作成しつつ、その場で修正してコミットするというのを試してみました。

git subtreeを使うのは初めてでしたが、開発コラボレーションのヒント from Atlassian Blogs (6) Git Submodule の代替: Git Subtree | マイナビニュース の記事がわかりやすくて助かりました。ありがとうございます!

実際に作成したプレーブックはhnakamur/macbook_setupにあります。

例えばmacbook_setup/hnakamur.direnv at master · hnakamur/macbook_setup
hnakamur/direnv-ansible_rolesubtree push してあります。

role作成の手順

私が試していた手順は以下のとおりです。hnakamur.direnv の例で説明します。

github上でroleのレポジトリを作成

githubのページの[Create new...]/[New repository]メニューでレポジトリを作ります。

git remoteを追加

git remote add direnv https://github.com/hnakamur/direnv-ansible_role

git subtreeを追加

git subtree add --prefix hnakamur.direnv direnv master

roleを開発して親レポジトリでコミット

roleのファイルを作成・修正したら親レポジトリでコミットします。

role毎のレポジトリにプッシュ

roleの開発が一区切りついたらプッシュしておきます。

git subtree push --prefix hnakamur.direnv direnv master
32
32
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

Qiita Conference 2025 will be held!: 4/23(wed) - 4/25(Fri)

Qiita Conference is the largest tech conference in Qiita!

Keynote Speaker

ymrl、Masanobu Naruse, Takeshi Kano, Junichi Ito, uhyo, Hiroshi Tokumaru, MinoDriven, Minorun, Hiroyuki Sakuraba, tenntenn, drken, konifar

View event details
32
32

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?