LoginSignup
0
0

More than 5 years have passed since last update.

MSYS2でansible

Last updated at Posted at 2019-02-26

install

インストール時はMinGWではなく、MSYSのターミナル (msys2.exe) を起動。

$ env | grep MSYSTEM=
MSYSTEM=MSYS

Python と pip を入れる

$ pacman -S python python3-pip

$ python -V
Python 3.7.1

$ pip -V
pip 18.1 from /usr/lib/python3.7/site-packages/pip (python 3.7)

依存ライブラリ/ツールとansible本体を入れる

$ pacman -S gcc make libffi-devel openssl-devel libcrypt-devel

$ pacman -S sshpass
$ sshpass.exe -V
sshpass 1.06

$ pip install ansible
### ビルドに1時間くらいかかった

$ ansible --version
ansible 2.7.8
  config file = None
  configured module search path = ['/home/pen/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.7.2 (default, Dec 26 2018, 08:10:46) [GCC 7.4.0]

動作確認(ローカル)

$ ansible localhost -m shell -a 'hostname'
localhost | CHANGED | rc=0 >>
gray2

$ ansible localhost -m setup -a 'filter=ansible_distribution*'
localhost | SUCCESS => {
    "ansible_facts": {
        "ansible_distribution": "MSYS_NT-10.0",
        "ansible_distribution_release": "2.11.1(0.329/5/3)",
        "ansible_distribution_version": "2018-09-10 14:19"
    },
    "changed": false
}

動作確認

$ cat inventory
[foo]
host1 ansible_host=xxx.xxx.xxx.xxx
host2 ansible_host=xxx.xxx.xxx.xxx
host3 ansible_host=xxx.xxx.xxx.xxx
host4 ansible_host=xxx.xxx.xxx.xxx
host5 ansible_host=xxx.xxx.xxx.xxx

$ cat ansible.cfg
[ssh_connection]
ssh_args = -o ForwardAgent=yes

$ ansible foo -i ./inventory -m shell -a 'cat /etc/*-release | head -n1' -o
host3 | CHANGED | rc=0 | (stdout) CentOS release 6.10 (Final)
host4 | CHANGED | rc=0 | (stdout) CentOS Linux release 7.6.1810 (Core)
host1 | CHANGED | rc=0 | (stdout) CentOS release 6.10 (Final)
host5 | CHANGED | rc=0 | (stdout) CentOS Linux release 7.6.1810 (Core)
host2 | CHANGED | rc=0 | (stdout) CentOS Linux release 7.6.1810 (Core)

$ ansible foo -i ./inventory -m shell -a 'rpm -qa | grep httpd-[[:digit:]] || true' -o
host3 | CHANGED | rc=0 | (stdout) httpd-2.2.15-69.el6.centos.x86_64
host4 | CHANGED | rc=0 | (stdout) httpd-2.4.6-88.el7.centos.x86_64
host5 | CHANGED | rc=0 | (stdout)
host2 | CHANGED | rc=0 | (stdout) httpd-2.4.6-88.el7.centos.x86_64
host1 | CHANGED | rc=0 | (stdout) httpd-2.2.15-69.el6.centos.x86_64

$ ansible foo -i ./inventory -m shell -a 'rpm -qa | grep ^mysql-.*server-[[:digit:]] || true' -o
host4 | CHANGED | rc=0 | (stdout) mysql-community-server-8.0.13-1.el7.x86_64
host3 | CHANGED | rc=0 | (stdout) mysql-community-server-5.7.24-1.el6.x86_64
host2 | CHANGED | rc=0 | (stdout)
host5 | CHANGED | rc=0 | (stdout)
host1 | CHANGED | rc=0 | (stdout) mysql-community-server-8.0.13-1.el6.x86_64

備考

過去に試したときは libffi が解決できず、CFLAGSを指定する必要があった。

2.7.8 では大丈夫になっていた。

CFLAGS=-I/usr/lib/libffi-3.2.1/include pip install ansible
0
0
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
0
0