-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NEW] added redis-server installation ansible playbook
- Loading branch information
1 parent
0d36923
commit 2181ab7
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[redis_servers] | ||
server1 ansible_host=34.69.104.233 ansible_user=ismoilovdev | ||
server2 ansible_host=34.27.32.115 ansible_user=ismoilovdev | ||
server3 ansible_host=34.170.180.55 ansible_user=ismoilovdev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
--- | ||
- name: Install and configure Redis | ||
hosts: redis_servers | ||
become: yes | ||
tasks: | ||
|
||
- name: Detect operating system family | ||
set_fact: | ||
os_family: "{{ ansible_os_family }}" | ||
|
||
# Ubuntu/Debian uchun Redis o'rnatish | ||
- name: Install Redis on Debian-based systems | ||
when: os_family == "Debian" | ||
block: | ||
- name: Install prerequisites | ||
apt: | ||
name: | ||
- lsb-release | ||
- curl | ||
- gpg | ||
state: present | ||
update_cache: yes | ||
|
||
- name: Add Redis GPG key | ||
apt_key: | ||
url: https://packages.redis.io/gpg | ||
state: present | ||
keyring: /usr/share/keyrings/redis-archive-keyring.gpg | ||
|
||
- name: Add Redis repository | ||
apt_repository: | ||
repo: "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb {{ ansible_distribution_release }} main" | ||
state: present | ||
|
||
- name: Update apt cache and install Redis | ||
apt: | ||
name: redis | ||
state: present | ||
update_cache: yes | ||
|
||
# RedHat/Rocky uchun Redis o'rnatish | ||
- name: Install Redis on RedHat-based systems | ||
when: os_family == "RedHat" | ||
block: | ||
- name: Install Redis package | ||
yum: | ||
name: redis | ||
state: present | ||
|
||
# Redis service-ni ishga tushirish va yoqish | ||
- name: Enable and start Redis service | ||
systemd: | ||
name: redis-server | ||
enabled: yes | ||
state: started | ||
|
||
# Konfiguratsiya faylini sozlash | ||
- name: Configure Redis to listen on all interfaces | ||
lineinfile: | ||
path: /etc/redis/redis.conf | ||
regexp: "^bind 127.0.0.1" | ||
line: "bind 0.0.0.0" | ||
state: present | ||
|
||
- name: Update Redis-server configuration - set protected-mode to no | ||
lineinfile: | ||
path: /etc/redis/redis.conf | ||
regexp: '^protected-mode' | ||
line: 'protected-mode no' | ||
state: present | ||
|
||
- name: Restart Redis service after configuration change | ||
systemd: | ||
name: redis-server | ||
state: restarted |