ansibleでの各roleのパス取得方法

playbookをrole毎に分けた際、roleの中でfilesのpath指定をするために実行中の/path/to/role/{current}を知りたくなった。 ref: Accessiing information about other hosts with magic variables ...

<span title='2018-10-15 00:00:00 +0000 UTC'>10月 15, 2018</span>&nbsp;·&nbsp;1 分

Ansibleでよく使うモジュール

blockinfile : 複数行を扱えるfileモジュール blockinfile - Insert/update/remove a text block surrounded by marker lines 1 2 3 4 5 6 7 8 9 10 11 12 - hosts: all roles: - yaegashi.blockinfile tasks: - name: 特定の場所に追加 blockinfile: path: ./test.txt insertafter: '^# xxxx' marker: "<!-- {mark} ANSIBLE MANAGED BLOCK -->" block: | 1行目 2行目 unarchive unarchive - Unpacks an archive after (optionally) copying it from the local machine. 1 2 3 4 5 6 7 8 9 10 11 12 - name: install peco become: yes unarchive: remote_src: yes src: "{{ peco_bin_url }}" dest: /usr/local/bin/ mode: 0755 owner: root group: root extra_opts: - --strip-components=1 - peco_linux_amd64/peco

<span title='2018-09-30 00:00:00 +0000 UTC'>9月 30, 2018</span>&nbsp;·&nbsp;1 分