概要
- Bash on Ubuntu on Windows(BoUoW)上に Ansible を導入して使うためのメモ
目標
- できるだけ新しい ansible (2.x) を導入して使える状態にしたい
- apt で解決したい
作業環境
- BoUoW バージョン確認:
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty
- ※ 以下は
sudo su -
で root環境で作業しているメモ。適時sudo
aptでansibleを取得できるか確認
apt search ansible
ソート中... 完了
全文検索... 完了
ansible-fireball/trusty 1.5.4+dfsg-1 all
Ansible fireball transport support
ansible-node-fireball/trusty 1.5.4+dfsg-1 all
Ansible fireball transport support for nodes
python-reclass/trusty 1.2.2-1 all
hierarchical inventory backend for configuration management systems
reclass/trusty 1.2.2-1 all
hierarchical inventory backend for configuration management systems
- 1.5.4 と 1.2.2 を使えるっぽいが 今回は2.x を使いたい…
PPAリポジトリを追加
apt-add-repository ppa:ansible/ansible
apt update
再度取得できるパッケージを確認
apt search ansible
ソート中... 完了
全文検索... 完了
ansible/trusty,now 2.3.2.0-1ppa~trusty all
A radically simple IT automation platform
ansible-doc/trusty 1.5.4+dfsg-1 all
Ansible documentation and examples
ansible-fireball/trusty 1.5.4+dfsg-1 all
Ansible fireball transport support
ansible-node-fireball/trusty 1.5.4+dfsg-1 all
Ansible fireball transport support for nodes
python-reclass/trusty 1.2.2-1 all
hierarchical inventory backend for configuration management systems
reclass/trusty 1.2.2-1 all
hierarchical inventory backend for configuration management systems
- 2.3.2 が増えた
インストール
apt install ansible
バージョン確認
ansible --version
ansible 2.3.2.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
python version = 2.7.6 (default, Oct 26 2016, 20:30:19) [GCC 4.8.4]
動作テスト
- ローカルホストにping を実行してみる
-
test.yml
playbookを作成する
- hosts: localhost
connection: local
tasks:
- ping:
ansible-playbook ./test.yml
[WARNING]: provided hosts list is empty, only localhost is available
PLAY [localhost] ***********************************************************
TASK [Gathering Facts] *****************************************************
ok: [localhost]
TASK [ping] ****************************************************************
ok: [localhost]
PLAY RECAP *****************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=0
- 正常に実行できた!