LoginSignup
0
0

More than 1 year has passed since last update.

Azure上のRHEL8にAnsibleをインストールする(RHAAP無しで)

Last updated at Posted at 2022-05-09

エンプラのITで偉い人ほど誤解しがちなことに、Red Hat Enterprise Linuxのサブスクリプションを持っていればAnsibleは簡単に使えるようになる、という事がある。
これってば、Red Hatのおそらく意図的なマーケティング上のミスリードであり、RHEL8があればRed HatによりサポートされるAnsibleがついてくるという事はない。RHEL8 OSのインストールディスクにAnsbileのrpmが入っているわけでもない。Red HatからサポートされるAnsbileが欲しかったらRed Hat Ansible Automation Platform(RHAAP)のサブスクリプションを買うしかない。

重要な事なのでもう一度書くが、RHAAPのサブスクリプションを持ってなけばRed HatがサポートするAnsibleは手に入らない。
逆に言えばRed Hatサポートがいらないなら、Ansibleの開発コミュティが提供するAnsibleを使ったところでサポート的な硬さは変わらない。それならばRHAAPのサブスクを持っていない場合のAnsibleはすべてのケースでAnsibleコミュニティ版を使おうぜと主張したい。EPEL使おうぜ。

まあ、subscription-manager repos --enable ansible-2.9-for-rhel-8-x86_64-rpmsが(サブスクリプションが無いと)どうにもAnsibleがインストールできず時間だけ消費される非生産性に頭にキタという事である。
Dockerの時も似たような罠があったが、Red Hatがいまいちクリーンで信用の置けるディストロとは言い難いと思う理由の一つでもある。

環境

AzureにRHEL8の仮想マシンを作る。サイズは何でもいいと思うが、OSはお勧めされたのでRHEL 8.2を選ぶ。
気が付いたのだが、Azureだと、OSがUbuntuでもRHELでもVMに価格差が無いことで、あれいつの間にRHEL無料になったんだっけと思ったがAWS EC2では価格差が健在である。うーん?(5/12追記:AzureでもRHEL OS料金は請求される。VM作成画面のバグ)

Red Hat on Microsoft Azure
https://access.redhat.com/ecosystem/microsoft-azure

on-demandイメージはMicrosoftがサポートして、Red HatのSubscriptionは消費しないと。・・・なるほど?まあ、タダ相当で使えるならそれに越したことは無い。

Ansibleをインストール

OSインスタンスを作って、SSHで接続。

おもむろにyum install ansibleと実行してみるが、当然失敗。

$ sudo -i
# yum install ansible
Red Hat Enterprise Linux 8 for x86_64 - BaseOS   11 MB/s |  38 MB     00:03
Red Hat Enterprise Linux 8 for x86_64 - AppStre 6.5 MB/s |  23 MB     00:03
Microsoft Azure RPMs for RHEL8 Extended Update  1.7 kB/s | 2.2 kB     00:01
Last metadata expiration check: 0:00:01 ago on Mon 09 May 2022 07:51:15 AM UTC.
No match for argument: ansible
Error: Unable to find a match: ansible

ええ、ええ、そうでしょうとも。/etc/yum.repos.d/にあるyumレポジトリも参照するに、baseosとappstreamのMicrosoftが維持しているレポジトリが参照されており、Ansibleのレポジトリはなさそうだ。

であるからして、今は亡きCentOS8と同様の手順でEPELからAnsibleをインストールしよう。
EPELもいつまで維持されるんだろうか。
https://docs.ansible.com/ansible/2.9_ja/installation_guide/intro_installation.html#rhelcentos-fedora-ansible

引用すると「現在サポートされている RHEL(中略)の RPM は、releases.ansible.com および EPEL から入手できます。」だ。

「codeready-builder」のサブスクリプションを有効にする手順が含まれているが、これはRed Hatお得意の嫌がらせであり、その下の「dnf install ~epel~」が実行できれば良い。

# dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

これでAnsibleがインストールできる。

# yum install ansible
...
================================================================================
 Package          Arch   Version       Repository                          Size
================================================================================
Installing:
 ansible          noarch 2.9.27-1.el8  epel                                17 M
Installing dependencies:
 libsodium        x86_64 1.0.18-2.el8  epel                               162 k
 python3-bcrypt   x86_64 3.1.6-2.el8.1 epel                                44 k
 python3-jmespath noarch 0.9.0-11.el8  rhel-8-for-x86_64-appstream-eus-rhui-rpms
                                                                           45 k
 python3-pynacl   x86_64 1.3.0-5.el8   epel                               100 k
 sshpass          x86_64 1.06-9.el8    epel                                27 k
Installing weak dependencies:
 python3-paramiko noarch 2.4.3-2.el8   epel                               290 k

Transaction Summary
================================================================================
Install  7 Packages

Total download size: 18 M
Installed size: 99 M
Is this ok [y/N]: y
...

localhost相手にansibleコマンドが実行できるかを確認する。

$ ansible localhost -a "echo hello world"
localhost | CHANGED | rc=0 >>
hello world

ssh鍵を作って、公開鍵を確認する。

$ ssh-keygen -f ~/.ssh/id_rsa -N ""
$ cat ~/.ssh/id_rsa.pub

その公開鍵を使って、管理対象となるもう一台のRHEL8マシンを作る。
VMが出来たら、Ansibleマシンから管理対象のマシンへsshアクセスを試し、ansibleを実行。

$ ssh managed
The authenticity of host 'managed (10.0.0.5)' can't be established.
ECDSA key fingerprint is SHA256:1ph6SLdRn7yctUpvygT065iCD710OUVTZ4wXEiXGiAE.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'managed' (ECDSA) to the list of known hosts.
Activate the web console with: systemctl enable --now cockpit.socket

This system is not registered to Red Hat Insights. See https://cloud.redhat.com/
To register this system, run: insights-client --register

Last login: Mon May  9 09:48:25 2022 from 10.0.0.4
[azureuser@managed ~]$ exit

$ echo managed>inventory
$ ansible -i ./inventory managed -a "hostname"
managed | CHANGED | rc=0 >>
managed

いやー、Azure+RHEL+Ansible面倒くさい。

なお、将来的にはお金を払ってRed Hatサポートを受けたいが今はたまたま会社的な都合でRHAAPのサブスクが用意できない。OSS無理だし。絶対サポート必要だし。という事であれば、当面は60日評価版を使って問題を先送りする事も出来る。
Azure VMだと、800MB強のtar.gzファイルが/home/azureuserではディスク容量が足らなくて展開できないという絶妙にイライラするUser Experienceを得られるが。

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