Initial commit
This commit is contained in:
parent
ecd28e9b97
commit
570e069ded
4
inventory.yml
Executable file
4
inventory.yml
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
ungrouped:
|
||||||
|
hosts:
|
||||||
|
ansible-test:
|
||||||
|
ansible_host: 192.168.102.4
|
13
main.yml
Executable file
13
main.yml
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
- name: run common tasks
|
||||||
|
hosts: all
|
||||||
|
become: true
|
||||||
|
become_user: root
|
||||||
|
gather_facts: true
|
||||||
|
roles:
|
||||||
|
- common
|
||||||
|
|
||||||
|
#- name: run host-specific tasks
|
||||||
|
# hosts: all
|
||||||
|
# become: true
|
||||||
|
# become_user: root
|
||||||
|
# roles: "{{inventory_hostname}}"
|
15
roles/common/files/etc/nginx/sites-available/default
Executable file
15
roles/common/files/etc/nginx/sites-available/default
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
server {
|
||||||
|
listen 80 default_server;
|
||||||
|
listen [::]:80 default_server;
|
||||||
|
# SSL configuration
|
||||||
|
listen 443 ssl default_server;
|
||||||
|
listen [::]:443 ssl default_server;
|
||||||
|
include snippets/snakeoil.conf;
|
||||||
|
|
||||||
|
root /var/www/default;
|
||||||
|
index index.html;
|
||||||
|
server_name _;
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ =404;
|
||||||
|
}
|
||||||
|
}
|
1
roles/common/files/etc/rsyslog.d/20-remote.conf
Executable file
1
roles/common/files/etc/rsyslog.d/20-remote.conf
Executable file
@ -0,0 +1 @@
|
|||||||
|
# dummy file (man nav syslog servera)
|
14
roles/common/handlers/main.yml
Executable file
14
roles/common/handlers/main.yml
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
- name: Restart rsyslog
|
||||||
|
systemd_service:
|
||||||
|
name: rsyslog
|
||||||
|
state: restarted
|
||||||
|
|
||||||
|
- name: Reload nginx
|
||||||
|
systemd_service:
|
||||||
|
name: nginx
|
||||||
|
state: reloaded
|
||||||
|
|
||||||
|
- name: Restart nginx
|
||||||
|
systemd_service:
|
||||||
|
name: nginx
|
||||||
|
state: restarted
|
0
roles/common/tasks/ldap.yml
Executable file
0
roles/common/tasks/ldap.yml
Executable file
26
roles/common/tasks/main.yml
Executable file
26
roles/common/tasks/main.yml
Executable file
@ -0,0 +1,26 @@
|
|||||||
|
- name: Install basic packages
|
||||||
|
ansible.builtin.package:
|
||||||
|
name:
|
||||||
|
- neovim
|
||||||
|
- htop
|
||||||
|
- git
|
||||||
|
- curl
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Set a hostname
|
||||||
|
ansible.builtin.hostname:
|
||||||
|
name: "{{inventory_hostname}}"
|
||||||
|
|
||||||
|
- name: Set default hosts file
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: etc/hosts
|
||||||
|
dest: /etc/hosts
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
|
||||||
|
- name: Import syslog.yml
|
||||||
|
import_tasks: syslog.yml
|
||||||
|
|
||||||
|
- name: Import webserver.yml
|
||||||
|
import_tasks: webserver.yml
|
13
roles/common/tasks/syslog.yml
Executable file
13
roles/common/tasks/syslog.yml
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
- name: Install rsyslog
|
||||||
|
ansible.builtin.package:
|
||||||
|
name: rsyslog
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Copy rsyslog config
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: etc/rsyslog.d/20-remote.conf
|
||||||
|
dest: /etc/rsyslog.d/20-remote.conf
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
notify: Restart rsyslog
|
48
roles/common/tasks/webserver.yml
Executable file
48
roles/common/tasks/webserver.yml
Executable file
@ -0,0 +1,48 @@
|
|||||||
|
|
||||||
|
- name: Install webserver packages
|
||||||
|
ansible.builtin.package:
|
||||||
|
name:
|
||||||
|
- nginx
|
||||||
|
- ssl-cert # snakeoil certificates for default site
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Remove default website
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /var/www/html
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Create default site directory
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /var/www/default
|
||||||
|
state: directory
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0755
|
||||||
|
|
||||||
|
- name: Copy default index
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: var/www/default/index.html
|
||||||
|
dest: /var/www/default/index.html
|
||||||
|
owner: www-data
|
||||||
|
group: www-data
|
||||||
|
mode: 0640
|
||||||
|
|
||||||
|
- name: Copy default config
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: etc/nginx/sites-available/default
|
||||||
|
dest: /etc/nginx/sites-available/default
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
notify: Reload nginx
|
||||||
|
|
||||||
|
- name: Enable default config
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/nginx/sites-enabled/default
|
||||||
|
src: /etc/nginx/sites-available/default
|
||||||
|
state: link
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
|
||||||
|
|
7
roles/common/templates/etc/hosts
Executable file
7
roles/common/templates/etc/hosts
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
127.0.0.1 localhost
|
||||||
|
127.0.0.1 {{ inventory_hostname }}
|
||||||
|
|
||||||
|
# The following lines are desirable for IPv6 capable hosts
|
||||||
|
::1 localhost ip6-localhost ip6-loopback
|
||||||
|
ff02::1 ip6-allnodes
|
||||||
|
ff02::2 ip6-allrouters
|
9
roles/common/templates/var/www/default/index.html
Executable file
9
roles/common/templates/var/www/default/index.html
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h1>Welcome to {{inventory_hostname}} </h1>
|
||||||
|
<p>This is a paragraph</p>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
x
Reference in New Issue
Block a user