diff --git a/group_vars/all/ssh.yml b/group_vars/all/ssh.yml new file mode 100644 index 0000000..c3edd05 --- /dev/null +++ b/group_vars/all/ssh.yml @@ -0,0 +1,6 @@ +--- +ansible_connection: ssh +ansible_user: root +ansible_ssh_pass: prisnetajneheslo +ansible_ssh_common_args: '-o StrictHostKeyChecking=no' + diff --git a/play-4.yml b/play-4.yml index 6788184..adb8bf0 100644 --- a/play-4.yml +++ b/play-4.yml @@ -11,3 +11,14 @@ template: src: ./index.html.j2 dest: /var/www/html/index + register: homepage + + - name: Look into homepage var + debug: + var: homepage + + - name: Reload apache2 + systemd: + name: "apache2" + state: "reloaded" + when: homepage is changed diff --git a/play-4a.yml b/play-4a.yml new file mode 100644 index 0000000..eab504e --- /dev/null +++ b/play-4a.yml @@ -0,0 +1,34 @@ +--- +- name: Install web server + hosts: 7-ubuntu + handlers: + - name: Reload apache + systemd: + name: "apache2" + state: "reloaded" + + tasks: + - name: Install web server + package: + name: "apache2" + state: present + tags: install + + - name: Set homepage + template: + src: ./index.html.j2 + dest: /var/www/html/index.html + notify: Reload apache + tags: + - configure + - index + + - name: Set homepage2 + template: + src: ./index.html.j2 + dest: /var/www/html/index7.html + notify: Reload apache + tags: + - configure + - index + diff --git a/play-6.yml b/play-6.yml new file mode 100644 index 0000000..7b9322a --- /dev/null +++ b/play-6.yml @@ -0,0 +1,5 @@ +--- +- name: Install webserver - Apache2 + hosts: 7-ubuntu + roles: + - webserver_apache diff --git a/roles/webserver_apache/handlers/main.yml b/roles/webserver_apache/handlers/main.yml new file mode 100644 index 0000000..32d2989 --- /dev/null +++ b/roles/webserver_apache/handlers/main.yml @@ -0,0 +1,4 @@ +- name: Reload apache + systemd: + name: "apache2" + state: "reloaded" diff --git a/roles/webserver_apache/tasks/main.yml b/roles/webserver_apache/tasks/main.yml new file mode 100644 index 0000000..5b1181a --- /dev/null +++ b/roles/webserver_apache/tasks/main.yml @@ -0,0 +1,23 @@ +- name: Install web server + package: + name: "apache2" + state: present + tags: install + +- name: Set homepage + template: + src: ./index.html.j2 + dest: /var/www/html/index.html + notify: Reload apache + tags: + - configure + - index + +- name: Set homepage2 + template: + src: ./index.html.j2 + dest: /var/www/html/index7.html + notify: Reload apache + tags: + - configure + - index diff --git a/roles/webserver_apache/templates/index.html.j2 b/roles/webserver_apache/templates/index.html.j2 new file mode 100644 index 0000000..9256d6d --- /dev/null +++ b/roles/webserver_apache/templates/index.html.j2 @@ -0,0 +1,363 @@ + + + + + + Apache2 Ubuntu Default Page: It works + + + +
+ +
+
+

+ This is the default welcome page used to test the correct + operation of the Apache2 server after installation on Ubuntu systems. + It is based on the equivalent page on Debian, from which the Ubuntu Apache + packaging is derived. + If you can read this page, it means that the Apache HTTP server installed at + this site is working properly. You should replace this file (located at + /var/www/html/index.html) before continuing to operate your HTTP server. +

+ +

+ If you are a normal user of this web site and don't know what this page is + about, this probably means that the site is currently unavailable due to + maintenance. + If the problem persists, please contact the site's administrator. +

+ +
+
+
+ Configuration Overview +
+
+

+ Ubuntu's Apache2 default configuration is different from the + upstream default configuration, and split into several files optimized for + interaction with Ubuntu tools. The configuration system is + fully documented in + /usr/share/doc/apache2/README.Debian.gz. Refer to this for the full + documentation. Documentation for the web server itself can be + found by accessing the manual if the apache2-doc + package was installed on this server. +

+

+ The configuration layout for an Apache2 web server installation on Ubuntu systems is as follows: +

+
+/etc/apache2/
+|-- apache2.conf
+|       `--  ports.conf
+|-- mods-enabled
+|       |-- *.load
+|       `-- *.conf
+|-- conf-enabled
+|       `-- *.conf
+|-- sites-enabled
+|       `-- *.conf
+          
+
    +
  • + apache2.conf is the main configuration + file. It puts the pieces together by including all remaining configuration + files when starting up the web server. +
  • + +
  • + ports.conf is always included from the + main configuration file. It is used to determine the listening ports for + incoming connections, and this file can be customized anytime. +
  • + +
  • + Configuration files in the mods-enabled/, + conf-enabled/ and sites-enabled/ directories contain + particular configuration snippets which manage modules, global configuration + fragments, or virtual host configurations, respectively. +
  • + +
  • + They are activated by symlinking available + configuration files from their respective + *-available/ counterparts. These should be managed + by using our helpers + + a2enmod, + a2dismod, + + + a2ensite, + a2dissite, + + and + + a2enconf, + a2disconf + . See their respective man pages for detailed information. +
  • + +
  • + The binary is called apache2 and is managed using systemd, so to + start/stop the service use systemctl start apache2 and + systemctl stop apache2, and use systemctl status apache2 + and journalctl -u apache2 to check status. system + and apache2ctl can also be used for service management if + desired. + Calling /usr/bin/apache2 directly will not work with the + default configuration. +
  • +
+
+ +
+
+ Document Roots +
+ +
+

+ By default, Ubuntu does not allow access through the web browser to + any file outside of those located in /var/www, + public_html + directories (when enabled) and /usr/share (for web + applications). If your site is using a web document root + located elsewhere (such as in /srv) you may need to whitelist your + document root directory in /etc/apache2/apache2.conf. +

+

+ The default Ubuntu document root is /var/www/html. You + can make your own virtual hosts under /var/www. +

+
+ +
+
+ Reporting Problems +
+
+

+ Please use the ubuntu-bug tool to report bugs in the + Apache2 package with Ubuntu. However, check existing bug reports before reporting a new bug. +

+

+ Please report bugs specific to modules (such as PHP and others) + to their respective packages, not to the web server itself. +

+
+ +
+
+
+
+ + diff --git a/setup.yml b/setup.yml new file mode 100644 index 0000000..cf4f16a --- /dev/null +++ b/setup.yml @@ -0,0 +1,37 @@ +--- +name: Setup my system +hosts: all +tasks: + - name: Setup user + user: + name: fr + shell: /bin/bash + groups: + - dialout + - wheel + - docker + - libvirt + + - name: Set bash as default shell for root + user: + name: root + shell: /bin/bash + + - name: Software + tasks: + - name: Add non-free voidlinux repository + community.general.xbps: + name: void-repo-nonfree + state: present + + - name: Upgrade all packages + community.general.xbps: + upgrade: true + + # install packages here + + - name: Clear xbps cache + command: 'xbps-remove -O' + + - name: Purge old kernels + command: 'vkpurge rm all'