時の対処方法
事象
以下のPlaybookを実行したときに、タイトルのエラーが出力された
---
- hosts: "{{ hostname }}"
gather_facts: no
vars_prompt:
- name: username
prompt: "gitに接続するユーザーを入力してください"
private: no
- name: password
prompt: "パスワードを入力してください"
tasks:
- name: git clone
git:
version: master
repo: https://{{ username }}:{{ password }}@github.com/username/hogehoge.git
dest: "/srv/hogehoge"
accept_hostkey: yes
become: true
ignore_errors: true
git pullをリモートホストで実行する簡単なplaybookだけど、実行したときにエラーが出力された
Local modifications exist in repository (force=no).
原因
リモートホスト側のローカルリポジトリにてファイルを更新していたことが原因
ローカルホスト側で以下のコマンドを実行
$ git status --porcelain
M testfile.txt
testfile.txtがローカルリポジトリで変更されていることがわかる
どうやらansibleのgitモジュールはgit status –porcelainを実行して、もしローカル差分があった場合は中断するような処理となっているよう。
解決するにはローカルホストにログインして手動pullするしかない(ハズ)
もしくは
tasks:
- name: git pull
shell: git pull
とかでいけるのかな?(未検証)
コメント