dnf install oracle-epel-release-el9.x86_64 -y
dnf install ansible.noarch ansible-core.x86_64 -y
dnf install dnf-utils zip unzip git gcc gcc-c++ nodejs gettext device-mapper-persistent-data lvm2 bzip2 python3-pip wget -y
[root@ol95 ansible]# ansible --version
ansible [core 2.14.17]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.9/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.9.19 (main, Sep 11 2024, 00:00:00) [GCC 11.5.0 20240719 (Red Hat 11.5.0-2.0.1)] (/usr/bin/python3)
jinja version = 3.1.2
libyaml = True
[root@ol95 ansible]#
[root@ol95 ansible]# pwd
/etc/ansible
[root@ol95 ansible]# ll
total 8
-rw-r--r--. 1 root root 614 Oct 26 08:56 ansible.cfg
-rw-r--r--. 1 root root 1175 Oct 26 08:56 hosts
drwxr-xr-x. 2 root root 6 Oct 26 08:56 roles
[root@ol95 ansible]#
Server + Node
useradd devops
su - devops
ssh-keygen -t rsa
cd ~
cd .ssh
cat id_rsa
cat id_rsa.pub
[devops@node1 ~]$ cd .ssh/
[devops@node1 .ssh]$ ll
total 8
-rw------- 1 devops devops 2602 Nov 23 12:09 id_rsa
-rw-r--r-- 1 devops devops 566 Nov 23 12:09 id_rsa.pub
[devops@node1 .ssh]$ vi authorized_keys
[devops@node1 .ssh]$
Server
vi /etc/ansible/ansible.cfg
[defaults]
interpreter_python = auto_silent
vi /etc/ansible/hosts
[node]
node1 ansible_ssh_user=devops ansible_ssh_private_key_file=/home/devops/.ssh/id_rsa ansible_ssh_host=192.168.100.20
test
[root@ol95 installer]# ansible node --list-host
hosts (1):
node1
[root@ol95 installer]#
ansible node1 -m ping
ansible node1 -m shell -a "ip add | grep 192---
vi /etc/ansible/roles/playbook.yml
- hosts: all
become: yes
tasks:
- name: Install system updates for linux systems
yum:
name: '*'
state: latest
update_cache: yes.168.100"
[root@ol95 ansible]# ansible-playbook /etc/ansible/roles/playbook.yml
PLAY [all] *************************************************************************************************************************************************************************************************************
TASK [Gathering Facts] *************************************************************************************************************************************************************************************************
ok: [node1]
TASK [Install system updates for linux systems] ************************************************************************************************************************************************************************
ok: [node1]
PLAY RECAP *************************************************************************************************************************************************************************************************************
node1 : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
[root@ol95 ansible]#
===> Ansible CLI Demo End
===========================
===> Ansible WEB UI Start
dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
dnf remove -y runc
dnf install -y docker-ce --nobest
systemctl enable docker.service
systemctl start docker.service
systemctl status docker.service
docker info
[root@ol95 installer]# pwgen -N 1 -s 40
lRE99RGu6rHwjKW7n3gyFHFCLERXc46EFG7ZKPjR
pip install docker
pip install docker-compose
pip install docker==6.1.3
pip install requests==2.31.0
cd /opt
wget https://github.com/ansible/awx/archive/refs/tags/17.1.0.zip
unzip 17.1.0.zip
cd /opt/awx-17.1.0/installer
[root@ol95 installer]# pwd
/opt/awx-17.1.0/installer
[root@ol95 installer]# ll
total 20
-rw-r--r-- 1 root root 172 Mar 10 2021 build.yml
-rw-r--r-- 1 root root 437 Mar 10 2021 install.yml
-rw-r--r-- 1 root root 518 Nov 23 15:30 inventory
drwxr-xr-x 7 root root 99 Mar 10 2021 roles
[root@ol95 installer]#
vi inventory
================================
localhost ansible_connection=local ansible_python_interpreter="/usr/bin/env python3"
[all:vars]
dockerhub_base=ansible
awx_task_hostname=awx
awx_web_hostname=awxweb
postgres_data_dir="/opt/myawx/pgdocker"
host_port=80
host_port_ssl=443
docker_compose_dir="/opt/myawx/awxcompose"
pg_username=awx
pg_password=awxpass
pg_database=awx
pg_port=5432
admin_user=admin
admin_password=password
create_preload_data=True
secret_key=lRE99RGu6rHwjKW7n3gyFHFCLERXc46EFG7ZKPjR
awx_official=true
project_data_dir=/opt/myawx/projects
====================
ansible-playbook -i inventory install.yml
docker ps
[root@ol95 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6b8175957a67 ansible/awx:17.1.0 "/usr/bin/tini -- /u…" 4 hours ago Up 2 hours 8052/tcp awx_task
31b242c48f79 ansible/awx:17.1.0 "/usr/bin/tini -- /b…" 4 hours ago Up 2 hours 0.0.0.0:80->8052/tcp, [::]:80->8052/tcp awx_web
2b996f3365cf redis "docker-entrypoint.s…" 4 hours ago Up 2 hours 6379/tcp awx_redis
bf8e0975fa68 postgres:12 "docker-entrypoint.s…" 4 hours ago Up 2 hours 5432/tcp awx_postgres
[root@ol95 ~]#
docker exec -it awx_task bash
useradd awx
usermod -aG wheel awx
docker exec -it awx_web bash
useradd awx
usermod -aG wheel awx
bash-4.4# pwd
/var/lib/awx/projects/update
bash-4.4# ls -la
total 8
drwxr-xr-x 2 awx awx 44 Nov 23 10:29 .
drwxrwxrwx 3 awx awx 20 Nov 23 10:29 ..
-rwxrwxrwx 1 awx awx 172 Nov 23 08:33 playbook.yml
-rwxrwxrwx 1 awx awx 172 Nov 23 09:28 update.yml
bash-4.4#
bash-4.4# exit
exit
[root@ol95 installer]# netstat -antlp | grep LISTEN
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 5645/sshd: tony.che
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 868/cupsd
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2335/docker-proxy
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 869/sshd: /usr/sbin
tcp 0 0 127.0.0.1:4330 0.0.0.0:* LISTEN 2010/pmlogger
tcp 0 0 127.0.0.1:44321 0.0.0.0:* LISTEN 1277/pmcd
tcp6 0 0 ::1:631 :::* LISTEN 868/cupsd
tcp6 0 0 ::1:4330 :::* LISTEN 2010/pmlogger
tcp6 0 0 ::1:6010 :::* LISTEN 5645/sshd: tony.che
tcp6 0 0 :::80 :::* LISTEN 2351/docker-proxy
tcp6 0 0 :::22 :::* LISTEN 869/sshd: /usr/sbin
tcp6 0 0 ::1:44321 :::* LISTEN 1277/pmcd
[root@ol95 installer]#