Ansible #2 ตอน ติดตั้ง Ansible บน RHEL 7, CentOS 7 , Ubuntu 16.04 และ Debian 9

Damrongsak Reetanon
4 min readDec 22, 2017

--

  • ติดตั้ง Ansible บน Red Hat Enterprise Linux 7 (RHEL 7)
#- ลงทะเบียนกับ Red Hat Network ด้วยคำสั่ง subscription-manager
[root@ansible-rhel ~]# subscription-manager register --auto-attach
Registering to: subscription.rhsm.redhat.com:443/subscription
Username: <RHN-ID>
Password:
The system has been registered with ID: 05f1ae4e-0000-0000-0000-000000000000
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux Server
Status: Subscribed
#- ติดตั้ง epel-release เพื่อเพิ่มเติม EPEL (Extra Packages for Enterprise Linux) Repository
[root@ansible-rhel ~]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Retrieving https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
warning: /var/tmp/rpm-tmp.EzZo2D: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:epel-release-7-11 ################################# [100%]
#- ติดตั้ง Ansible ด้วยคำสั่ง yum
[root@ansible-rhel ~]# yum install -y ansible
Loaded plugins: search-disabled-repos
Resolving Dependencies
....... truncated output ............Installed:
ansible.noarch 0:2.4.2.0-1.el7
Complete!#- ตรวจสอบความถูกต้องในการติดตั้ง Ansible ด้วยคำสั่ง ansible --version
[root@ansible-rhel ~]# ansible --version
ansible 2.4.2.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /bin/ansible
python version = 2.7.5 (default, May 3 2017, 07:55:04) [GCC 4.8.5 20150623 (Red Hat 4.8.5-14)]
#- คำสั่งแสดง version ของ Red Hat Enterprise Linux
[root@ansible-rhel ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.4 (Maipo)
  • ติดตั้ง Ansible บน CentOS 7
#- ติดตั้ง epel-release เพื่อเพิ่มเติม EPEL (Extra Packages for Enterprise Linux) Repository
[root@ansible ~]# yum -y install epel-release
Loaded plugins: fastestmirror
....... truncated output .......Installed:
epel-release.noarch 0:7-9
Complete!#- ติดตั้ง Ansible ด้วยคำสั่ง yum
[root@ansible ~]# yum install -y ansible
Loaded plugins: fastestmirror
....... truncated output .......Installed:
ansible.noarch 0:2.4.2.0-1.el7

Complete!
#- ตรวจสอบความถูกต้องในการติดตั้ง Ansible ด้วยคำสั่ง ansible --version
[root@ansible ~]# ansible --version
ansible 2.4.2.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Aug 4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
#- คำสั่งแสดง version ของ CentOS
[root@ansible ~]# cat /etc/centos-release
CentOS Linux release 7.4.1708 (Core)
  • ติดตั้ง Ansible บน Ubuntu 16.04
drs@ansible-ubuntu:~$ sudo apt-get update
[sudo] password for drs:
Hit:1 http://th.archive.ubuntu.com/ubuntu xenial InRelease
Hit:2 http://th.archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:3 http://th.archive.ubuntu.com/ubuntu xenial-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu xenial-security InRelease
Reading package lists... Done

drs@ansible-ubuntu:~$ sudo apt-get install software-properties-common
[sudo] password for drs:
Reading package lists... Done
Building dependency tree
Reading state information... Done
software-properties-common is already the newest version (0.96.20.7).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
drs@ansible-ubuntu:~$ sudo apt-add-repository ppa:ansible/ansible
Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy. Avoid writing scripts or custom code to deploy and update your applications— automate in a language that approaches plain English, using SSH, with no agents to install on remote systems.
..... truncated output .....
gpg: key 7BB9C367: public key "Launchpad PPA for Ansible, Inc." imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
OK
drs@ansible-ubuntu:~$ sudo apt-get update
Hit:1 http://th.archive.ubuntu.com/ubuntu xenial InRelease
Hit:2 http://th.archive.ubuntu.com/ubuntu xenial-updates InRelease
..... truncated output .....Fetched 130 kB in 2s (54.4 kB/s)
Reading package lists... Done
drs@ansible-ubuntu:~$ sudo apt-get install ansible
Reading package lists... Done
Building dependency tree
Reading state information... Done
..... truncated output .....Setting up python-idna (2.0-3) ...
Setting up python-ipaddress (1.0.16-1) ...
Setting up python-pyasn1 (0.1.9-1) ...
Setting up python-cryptography (1.2.3-1ubuntu0.1) ...
Setting up ansible (2.4.2.0-1ppa~xenial) ...
drs@ansible-ubuntu:~$ ansible --version
ansible 2.4.2.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/drs/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.12 (default, Nov 20 2017, 18:23:56) [GCC 5.4.0 20160609]
drs@ansible-ubuntu:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial
  • ติดตั้ง Ansible บน Debian 9
root@ansible-debian9:~# echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" >> /etc/apt/sources.listroot@ansible-debian9:~# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
Executing: /tmp/apt-key-gpghome.lZKqiKxbe4/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
gpg: failed to start the dirmngr '/usr/bin/dirmngr': No such file or directory
gpg: connecting dirmngr at '/tmp/apt-key-gpghome.lZKqiKxbe4/S.dirmngr' failed: No such file or directory
gpg: keyserver receive failed: No dirmngr
root@ansible-debian9:~# apt-get update
Ign:1 cdrom://[Debian GNU/Linux 9.3.0 _Stretch_ - Official amd64 xfce-CD Binary-1 20171209-12:11] stretch InRelease
Ign:2 cdrom://[Debian GNU/Linux 9.3.0 _Stretch_ - Official amd64 xfce-CD Binary-1 20171209-12:11] stretch Release
Ign:3 cdrom://[Debian GNU/Linux 9.3.0 _Stretch_ - Official amd64 xfce-CD Binary-1 20171209-12:11] stretch/main all Packages
Hit:4 cdrom://[Debian GNU/Linux 9.3.0 _Stretch_ - Official amd64
Get:14 http://ppa.launchpad.net/ansible/ansible/ubuntu trusty/main Translation-en [326 B]
Fetched 16.8 kB in 1s (11.0 kB/s)
Reading package lists... Done
W: The repository 'cdrom://[Debian GNU/Linux 9.3.0 _Stretch_ - Official amd64 xfce-CD Binary-1 20171209-12:11] stretch Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.

N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
root@ansible-debian9:~# apt-get install ansible
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
.... truncated output ....Setting up python-ipaddress (1.0.17-1) ...
Setting up python-jinja2 (2.8-1) ...
Setting up python-cryptography (1.7.1-3) ...
Setting up python-paramiko (2.0.0-1) ...
Setting up ansible (2.4.2.0-1ppa~trusty) ...
root@ansible-debian9:~# ansible --version
ansible 2.4.2.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.13 (default, Nov 24 2017, 17:33:09) [GCC 6.3.0 20170516]
root@ansible-debian9:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 9.3 (stretch)
Release: 9.3
Codename: stretch

--

--

Damrongsak Reetanon
Damrongsak Reetanon

Written by Damrongsak Reetanon

OpenSource |Cloud Computing|Automation|DevOps

No responses yet