adding users and roles

This commit is contained in:
Caleb Fultz 2024-07-13 23:10:41 -04:00
parent 164f342eaa
commit f7ffab31d9
9 changed files with 124 additions and 28 deletions

View File

@ -27,11 +27,10 @@
- htop
- neofetch
- hosts: web_servers
become: true
tags: debian
tasks:
- name: Install apache on web servers
@ -50,19 +49,6 @@
group: root
mode: 0644
- name: Add lfultz account
tags: debian
user:
name: lfultz
comment: Logan Fultz
uid: 1040
gid: 1040
group: sudo
shell: /bin/bash
generate_ssh_key: yes
ssh_key_bits: 2048
ssh_key_file: .ssh/id_rsa
- hosts: db_servers
tags: db, el
@ -73,16 +59,3 @@
package:
name: mariadb
state: latest
- name: Add lfultz account
tags: el
user:
name: lfultz
comment: Logan Fultz
uid: 1040
gid: 1040
group: wheel
shell: /bin/bash
generate_ssh_key: yes
ssh_key_bits: 2048
ssh_key_file: .ssh/id_rsa

5
09-roles/ansible.cfg Normal file
View File

@ -0,0 +1,5 @@
[defaults]
inventory = inventory
private_key_file = ~/.ssh/hetzner

View File

@ -0,0 +1,15 @@
---
- hosts: all
become: true
tasks:
#### Ubuntu/Debian Section ####
- name: Install apache2 package with php support
package:
name:
- "{{ apache_package }}"
- "{{ php_package }}"
state: latest
update_cache: yes

7
09-roles/inventory Normal file
View File

@ -0,0 +1,7 @@
[web_servers]
10.0.0.7
10.0.0.8
[db_servers]
10.0.0.5
10.0.0.11

View File

@ -0,0 +1,25 @@
- name: Install common packages
package:
name:
- htop
- neofetch
- name: Add lfultz account
tags: lfultz
user:
name: lfultz
comment: Logan Fultz
uid: 1040
groups: root
append: yes
shell: /bin/bash
generate_ssh_key: yes
ssh_key_bits: 2048
ssh_key_file: .ssh/id_rsa
- name: Add lfultz group
tags: group
group:
name: lfultz
state: present
gid: 1040

View File

@ -0,0 +1,5 @@
---
- name: install mariadb package on db servers
package:
name: mariadb
state: latest

View File

@ -0,0 +1,11 @@
<html>
<head>
<title>Website test</title>
</head>
<body>
<p> Goodevening Caleb </p>
</body>
</html>

View File

@ -0,0 +1,16 @@
---
- name: Install apache on web servers
tags: apache
package:
name:
- apache2
- libapache2-mod-php
- name: Copy html file
tags: website
copy:
src: default_site.html
dest: /var/www/html/index.html
owner: root
group: root
mode: 0644

39
09-roles/site.yml Normal file
View File

@ -0,0 +1,39 @@
---
- hosts: all
become: true
pre_tasks:
- name: install updates for RHEL distros
tags: always
package:
update_only: yes
update_cache: yes
when: ansible_os_family == "RedHat"
- name: install updates for Debian distros
tags: always
package:
upgrade: dist
update_cache: yes
when: ansible_os_family == "Debian"
- hosts: all
become: true
roles:
- base
- hosts: web_servers
become: true
tags: web
roles:
- web_servers
- hosts: db_servers
tags: db,
become: true
roles:
- db_servers