-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdbserver.yaml
More file actions
86 lines (73 loc) · 2.3 KB
/
dbserver.yaml
File metadata and controls
86 lines (73 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
- name: Setup Database Server
hosts: dbserver
become: true
vars_prompt:
- name: "mongo_password"
prompt: "Enter the MongoDB password for user 'kundanvyas197'"
private: yes
tasks:
- name: Update the apt cache
apt:
update_cache: yes
- name: Install gnupg and curl
apt:
name:
- gnupg
- curl
state: present
- name: Import MongoDB public key
shell: |
curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | gpg --dearmor -o /usr/share/keyrings/mongodb-server-8.0.gpg
args:
executable: /bin/bash
creates: /usr/share/keyrings/mongodb-server-8.0.gpg
- name: Add MongoDB repository
copy:
content: |
deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse
dest: /etc/apt/sources.list.d/mongodb-org-8.0.list
- name: Update the apt cache again after adding MongoDB repo
apt:
update_cache: yes
- name: Install MongoDB
apt:
name: mongodb-org
state: present
- name: Install MongoDB shell
apt:
name: mongodb-mongosh
state: present
- name: Start MongoDB service
service:
name: mongod
state: started
enabled: true
- name: Connect to MongoDB Atlas and verify connection
shell: |
echo "{{ mongo_password }}" | mongosh "mongourl
args:
executable: /bin/bash
register: mongo_connection
changed_when: false
- name: Display MongoDB connection output
debug:
var: mongo_connection.stdout
# Install Prometheus Node Exporter
- name: Install Prometheus Node Exporter
apt:
name: prometheus-node-exporter
state: present
# Start Prometheus Node Exporter
- name: Start and enable Prometheus Node Exporter service
systemd:
name: prometheus-node-exporter
state: started
enabled: true
# Verify Node Exporter is running
- name: Check status of Node Exporter
command: systemctl status prometheus-node-exporter
register: node_exporter_status
changed_when: false
- name: Display Node Exporter status
debug:
var: node_exporter_status.stdout