diff --git a/blogs.yaml b/blogs.yaml index 4b2d672..8e294e1 100644 --- a/blogs.yaml +++ b/blogs.yaml @@ -6,3 +6,5 @@ - hosts: blogs roles: - role: wordpress + site_names: + - kaos diff --git a/destroy_container.yaml b/destroy_container.yaml index 1272c4c..5ee3e73 100644 --- a/destroy_container.yaml +++ b/destroy_container.yaml @@ -5,10 +5,10 @@ prompt: 'what container should be destroyed?' private: no - name: confirm1 - prompt: 'are you sure you want to delete the container?' + prompt: 'are you sure you want to delete the container (NO/yes)?' private: no - name: confirm2 - prompt: 'if you really are sure, enter "cthulhu" backwards' + prompt: 'if you really are sure, enter the container name again' private: no tasks: - block: @@ -22,4 +22,4 @@ lxc_container: name: "{{ container_name }}" state: absent - when: "confirm1 == 'yes' and confirm2 == 'uhluhtc'" + when: "confirm1 == 'yes' and confirm2 == '{{ container_name }}'" diff --git a/ldap_server.yaml b/ldap.yaml similarity index 100% rename from ldap_server.yaml rename to ldap.yaml diff --git a/prepare_host.yaml b/prepare_host.yaml index caf0f4f..986b7b3 100644 --- a/prepare_host.yaml +++ b/prepare_host.yaml @@ -2,13 +2,23 @@ - hosts: vm_hosts tasks: - name: install lxc related packages - apt: name={{ item }} state=latest + apt: + name: "{{ item }}" + state: present + update_cache: yes + cache_valid_time: 3600 with_items: - lxc - python - python-lxc - name: install bridge utilities - apt: name=bridge-utils state=latest + apt: + name: "{{ item }}" + state: present + update_cache: yes + cache_valid_time: 3600 + with_items: + - bridge-utils notify: restart networking # We should fix this bug. We really should. It's a bug. # Bridge-utils requires a complete system reboot to enable the new bridge. @@ -18,7 +28,11 @@ dest: /etc/network/interfaces notify: restart networking - name: install utilities - apt: name={{ item }} state=latest + apt: + name: "{{ item }}" + state: present + update_cache: yes + cache_valid_time: 3600 with_items: - vim - htop @@ -37,4 +51,3 @@ service: name=networking state=reloaded - name: restart sshd service: name=networking state=reloaded - diff --git a/projects_server.yaml b/projects_server.yaml deleted file mode 100644 index 776ce85..0000000 --- a/projects_server.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- -- hosts: biff - roles: - - role: lxc_guest - vm_name: projects - distro: sid -- hosts: projects - roles: - - role: gitlab - gitlab_fqdn: "{{ inventory_hostname }}.lilik.it" diff --git a/roles/apache2/handlers/main.yaml b/roles/apache2/handlers/main.yaml index 20ae0f2..0074fe4 100644 --- a/roles/apache2/handlers/main.yaml +++ b/roles/apache2/handlers/main.yaml @@ -3,11 +3,3 @@ # static: yes # see static include issue: https://github.com/ansible/ansible/issues/13485 vars: service_name: apache2 - -- name: enable apache2 configuration - file: - src: "/etc/apache2/sites-available/{{ config_name }}" - dest: "/etc/apache2/sites-enabled/{{ config_name }}" - state: link - when: config_name is defined - notify: restart apache2 diff --git a/roles/apache2/tasks/main.yaml b/roles/apache2/tasks/main.yaml index 8f3b628..e969a7a 100644 --- a/roles/apache2/tasks/main.yaml +++ b/roles/apache2/tasks/main.yaml @@ -11,9 +11,29 @@ notify: restart apache2 - name: install apache2 libapache2-mod-php5 - apt: name="{{ item }}" state=present + apt: + name: "{{ item }}" + state: present + update_cache: yes + cache_valid_time: 3600 with_items: - libapache2-mod-php5 when: php | bool notify: - restart apache2 + +- name: add apache2 configurations + template: + src: ../../{{ parent_role_path }}/templates/{{ item }}.apache2.j2 + dest: /etc/apache2/sites-available/{{ item }} + when: config_names is defined + with_items: "{{ config_names }}" + +- name: enable apache2 configurations + file: + src: "/etc/apache2/sites-available/{{ item }}" + dest: "/etc/apache2/sites-enabled/{{ item }}" + state: link + with_items: "{{ config_names }}" + when: config_names is defined + notify: restart apache2 diff --git a/roles/dokuwiki/meta/main.yaml b/roles/dokuwiki/meta/main.yaml index 124178b..6a02c98 100644 --- a/roles/dokuwiki/meta/main.yaml +++ b/roles/dokuwiki/meta/main.yaml @@ -2,3 +2,4 @@ dependencies: - role: nginx php: true + parent_role_path: "dokuwiki" diff --git a/roles/dokuwiki/tasks/main.yaml b/roles/dokuwiki/tasks/main.yaml index fed8342..16ea3f7 100644 --- a/roles/dokuwiki/tasks/main.yaml +++ b/roles/dokuwiki/tasks/main.yaml @@ -1,12 +1,11 @@ --- - name: install dokuwiki and associated packages - apt: name={{ item }} state=latest + apt: + name: "{{ item }}" + state: present + update_cache: yes + cache_valid_time: 3600 with_items: - dokuwiki -- name: add nginx config for docukiwi - template: - src: docuwiki_nginx.j2 - dest: "/etc/nginx/sites-available/{{ config_name }}" notify: - - enable nginx configuration - restart nginx diff --git a/roles/dokuwiki/templates/docuwiki_nginx.j2 b/roles/dokuwiki/templates/dokuwiki.conf.nginx.j2 similarity index 100% rename from roles/dokuwiki/templates/docuwiki_nginx.j2 rename to roles/dokuwiki/templates/dokuwiki.conf.nginx.j2 diff --git a/roles/dokuwiki/templates/docuwiki_nginx.j2.TODO b/roles/dokuwiki/templates/dokuwiki.conf.nginx.j2.TODO similarity index 100% rename from roles/dokuwiki/templates/docuwiki_nginx.j2.TODO rename to roles/dokuwiki/templates/dokuwiki.conf.nginx.j2.TODO diff --git a/roles/dokuwiki/vars/main.yml b/roles/dokuwiki/vars/main.yml index a600fe9..ff70b0a 100644 --- a/roles/dokuwiki/vars/main.yml +++ b/roles/dokuwiki/vars/main.yml @@ -1 +1,2 @@ -config_name: docuwiki.conf +config_names: + - dokuwiki diff --git a/roles/mattermost/tasks/main.yaml b/roles/mattermost/tasks/main.yaml index 37a376e..a53b853 100644 --- a/roles/mattermost/tasks/main.yaml +++ b/roles/mattermost/tasks/main.yaml @@ -1,5 +1,9 @@ - name: install postgresql - apt: name={{ item }} state=latest + apt: + name: "{{ item }}" + state: present + update_cache: yes + cache_valid_time: 3600 with_items: - postgresql - postgresql-contrib diff --git a/roles/mysql/tasks/main.yaml b/roles/mysql/tasks/main.yaml index 895073c..ab2fb5a 100644 --- a/roles/mysql/tasks/main.yaml +++ b/roles/mysql/tasks/main.yaml @@ -3,4 +3,4 @@ vars: service_name: mysql service_packages: - - mysql + - mysql-server diff --git a/roles/nginx/handlers/main.yaml b/roles/nginx/handlers/main.yaml index aa89734..ad85682 100644 --- a/roles/nginx/handlers/main.yaml +++ b/roles/nginx/handlers/main.yaml @@ -3,14 +3,9 @@ # static: yes # see static include issue: https://github.com/ansible/ansible/issues/13485 vars: service_name: nginx + service_packages: + - nginx - name: validate nginx configuration command: nginx -t -c /etc/nginx/nginx.conf changed_when: False - -- name: enable nginx configuration - file: - src: "/etc/nginx/sites-available/{{ config_name }}" - dest: "/etc/nginx/sites-enabled/{{ config_name }}" - state: link - notify: restart nginx diff --git a/roles/nginx/tasks/main.yaml b/roles/nginx/tasks/main.yaml index 53081da..a45bbb5 100644 --- a/roles/nginx/tasks/main.yaml +++ b/roles/nginx/tasks/main.yaml @@ -11,7 +11,11 @@ notify: restart nginx - name: install php5-fpm - apt: name={{ item }} state=latest + apt: + name: "{{ item }}" + state: present + update_cache: yes + cache_valid_time: 3600 with_items: - php5-fpm when: php | bool @@ -26,3 +30,19 @@ notify: - enable nginx configuration - restart nginx + +- name: add nginx configurations + template: + src: "roles/{{ parent_role_path }}/templates/{{ item }}.conf.nginx.j2" + dest: /etc/nginx/sites-available/{{ item }}.conf + with_items: "{{ config_names }}" + when: config_names is defined + +- name: enable nginx configurations + file: + src: "/etc/nginx/sites-available/{{ item }}.conf" + dest: "/etc/nginx/sites-enabled/{{ item }}.conf" + state: link + with_items: "{{ config_names }}" + when: config_names is defined + notify: restart nginx diff --git a/roles/postgres/main.yaml b/roles/postgres/main.yaml deleted file mode 100644 index f1c6884..0000000 --- a/roles/postgres/main.yaml +++ /dev/null @@ -1,15 +0,0 @@ ---- -- include: service.yaml - vars: - service_name: nginx - -- name: validate nginx configuration - command: nginx -t -c /etc/nginx/nginx.conf - changed_when: False - -- name: enable nginx configuration - file: - src: "/etc/nginx/sites-available/{{ config_name }}" - dest: "/etc/nginx/sites-enabled/{{ config_name }}" - state: link - notify: restart nginx diff --git a/roles/postgres/tasks/main.yaml b/roles/postgres/tasks/main.yaml deleted file mode 100644 index a2c96af..0000000 --- a/roles/postgres/tasks/main.yaml +++ /dev/null @@ -1,17 +0,0 @@ ---- -- include: service.yaml - vars: - service_name: nginx - service_packages: - - nginx -- name: disable nginx default configuration - file: path=/etc/nginx/sites-enabled/default state=absent - notify: restart nginx -- name: upload nginx proxy configuration - template: - src: proxy_config.j2 - dest: "/etc/nginx/sites-available/{{ config_name }}" - when: is_proxy | bool - notify: - - enable nginx configuration - - restart nginx diff --git a/roles/postgres/handlers/main.yaml b/roles/postgresql/handlers/main.yaml similarity index 55% rename from roles/postgres/handlers/main.yaml rename to roles/postgresql/handlers/main.yaml index 6d04c98..583cd81 100644 --- a/roles/postgres/handlers/main.yaml +++ b/roles/postgresql/handlers/main.yaml @@ -1,4 +1,4 @@ --- - include: service.yaml vars: - service_name: postgres + service_name: postgresql diff --git a/roles/postgres/tasks0/main.yaml b/roles/postgresql/tasks/main.yaml similarity index 81% rename from roles/postgres/tasks0/main.yaml rename to roles/postgresql/tasks/main.yaml index 190c804..2949090 100644 --- a/roles/postgres/tasks0/main.yaml +++ b/roles/postgresql/tasks/main.yaml @@ -1,7 +1,7 @@ --- - include: service.yaml vars: - service_name: postgres + service_name: postgresql service_packages: - postgresql - postgresql-contrib diff --git a/roles/roundcube/meta/main.yaml b/roles/roundcube/meta/main.yaml index 8b662c9..8c7674e 100644 --- a/roles/roundcube/meta/main.yaml +++ b/roles/roundcube/meta/main.yaml @@ -1,3 +1,5 @@ --- dependencies: - role: nginx + php: true + parent_role_path: "roundcube" diff --git a/roles/roundcube/tasks/main.yaml b/roles/roundcube/tasks/main.yaml index c04552d..8f8064f 100644 --- a/roles/roundcube/tasks/main.yaml +++ b/roles/roundcube/tasks/main.yaml @@ -3,17 +3,30 @@ - name: install roundcube packages apt: - name: '{{ item }}' - state: latest - update_cache: yes + name: "{{ item }}" + state: present + update_cache: yes + cache_valid_time: 3600 with_items: - roundcube-sqlite3 - roundcube - roundcube-plugins -- name: add nginx config for roundcube - template: - src: roundcube_nginx.j2 - dest: "/etc/nginx/sites-available/{{ config_name }}" notify: - - enable nginx configuration - restart nginx + +- name: copy lilik-150x54.png + copy: + src: lilik-150x54.png + dest: /usr/share/roundcube/skins/classic/images/ + +- name: copy my-roundcube.php + template: + src: "my-roundcube.php.j2" + dest: "/etc/roundcube/my-roundcube.php" + mode: 0600 + +- name: include my-roundcube.php + lineinfile: + dest: /etc/roundcube/config.inc.php + insertafter: '\?>' + line: include_once("/etc/roundcube/my-roundcube.php"); diff --git a/roles/roundcube/templates/my-roundcube.php.j2 b/roles/roundcube/templates/my-roundcube.php.j2 new file mode 100644 index 0000000..2993274 --- /dev/null +++ b/roles/roundcube/templates/my-roundcube.php.j2 @@ -0,0 +1,21 @@ + array( + 'verify_peer' => false, + 'verfify_peer_name' => false, + ), +); diff --git a/roles/roundcube/templates/roundcube_nginx.j2 b/roles/roundcube/templates/roundcube.conf.nginx.j2 similarity index 100% rename from roles/roundcube/templates/roundcube_nginx.j2 rename to roles/roundcube/templates/roundcube.conf.nginx.j2 diff --git a/roles/roundcube/vars/main.yml b/roles/roundcube/vars/main.yml index 99a5b37..f15ff9b 100644 --- a/roles/roundcube/vars/main.yml +++ b/roles/roundcube/vars/main.yml @@ -1 +1,2 @@ -config_name: roundcube.conf +config_names: + - roundcube diff --git a/roles/sympa/meta/main.yaml b/roles/sympa/meta/main.yaml index 8b662c9..140047c 100644 --- a/roles/sympa/meta/main.yaml +++ b/roles/sympa/meta/main.yaml @@ -1,3 +1,4 @@ --- dependencies: - role: nginx + parent_role_path: "sympa" diff --git a/roles/sympa/tasks/main.yaml b/roles/sympa/tasks/main.yaml index 52c2d15..b3b67fb 100644 --- a/roles/sympa/tasks/main.yaml +++ b/roles/sympa/tasks/main.yaml @@ -1,14 +1,13 @@ --- - name: install sympa and associated packages - apt: name={{ item }} state=latest + apt: + name: "{{ item }}" + state: present + update_cache: yes + cache_valid_time: 3600 with_items: - sympa - wwsympa - fcgiwrap -- name: add nginx config for sympa - template: - src: sympa_nginx.j2 - dest: "/etc/nginx/sites-available/{{ config_name }}" notify: - - enable nginx configuration - restart nginx diff --git a/roles/sympa/templates/sympa_nginx.j2 b/roles/sympa/templates/sympa.conf.nginx.j2 similarity index 100% rename from roles/sympa/templates/sympa_nginx.j2 rename to roles/sympa/templates/sympa.conf.nginx.j2 diff --git a/roles/sympa/vars/main.yml b/roles/sympa/vars/main.yml index aeeb603..12e60c6 100644 --- a/roles/sympa/vars/main.yml +++ b/roles/sympa/vars/main.yml @@ -1 +1,2 @@ -config_name: sympa.conf +config_names: + - sympa diff --git a/roles/wordpress/meta/main.yaml b/roles/wordpress/meta/main.yaml index 0514b7a..fa6d857 100644 --- a/roles/wordpress/meta/main.yaml +++ b/roles/wordpress/meta/main.yaml @@ -2,3 +2,5 @@ dependencies: - role: apache2 php: true + parent_role_path: "wordpress" + - role: mysql diff --git a/roles/wordpress/tasks/main.yaml b/roles/wordpress/tasks/main.yaml index d9dc683..4d789a2 100644 --- a/roles/wordpress/tasks/main.yaml +++ b/roles/wordpress/tasks/main.yaml @@ -1,5 +1,74 @@ --- - name: install wordpress - apt: name={{ item }} state=latest + apt: + name: "{{ item }}" + state: present + update_cache: yes + cache_valid_time: 3600 with_items: - wordpress + notify: restart apache2 + +- name: install inetutils-ping + apt: + name: "{{ item }}" + state: present + update_cache: yes + cache_valid_time: 3600 + with_items: + - inetutils-ping + +- name: unarchive setup-mysql.gz +# unarchive dosn't support .gz file +# unarchive: src=/usr/share/doc/wordpress/examples/setup-mysql.gz dest=/usr/share/doc/wordpress/examples/ remote_src=yes copy=no +# use shell command instead + shell: gunzip -d -k setup-mysql.gz + args: + chdir: /usr/share/doc/wordpress/examples/ + creates: setup-mysql + +- name: make setup-mysql executable + file: + path: /usr/share/doc/wordpress/examples/setup-mysql + mode: u=rwx,g=rx,o=rx + +- name: add apache2 configurations for wordpress + template: + src: "wordpress.apache2.j2" + dest: "/etc/apache2/sites-available/{{ item }}.conf" + when: site_names is defined + with_items: "{{ site_names }}" + +- name: enable apache2 configuration + file: + src: "/etc/apache2/sites-available/{{ item }}.conf" + dest: "/etc/apache2/sites-enabled/{{ item }}.conf" + state: link + with_items: "{{ site_names }}" + when: site_names is defined + notify: restart apache2 + +- name: add sites to hosts + lineinfile: + dest: /etc/hosts + line: "127.0.0.1 {{ item }}" + when: site_names is defined + with_items: "{{ site_names }}" + +- name: create wordpress databases + shell: "/usr/share/doc/wordpress/examples/setup-mysql -n {{ item }} {{ item }}.lilik.it" + args: + creates: /etc/wordpress/config-{{ item }}.lilik.it.php + when: site_names is defined + with_items: "{{ site_names }}" + +- name: edit wordpress configurations + blockinfile: + dest: /etc/wordpress/config-{{ item }}.lilik.it.php + block: | + define('DB_CHARSET', 'utf8'); + define( 'FS_METHOD', 'direct'); + define ('WPLANG','it_IT'); + insertbefore: '\?>' + when: site_names is defined + with_items: "{{ site_names }}" diff --git a/roles/wordpress/templates/wordpress.apache2.j2 b/roles/wordpress/templates/wordpress.apache2.j2 new file mode 100644 index 0000000..9f3f28f --- /dev/null +++ b/roles/wordpress/templates/wordpress.apache2.j2 @@ -0,0 +1,11 @@ + + ServerName {{ item }}.lilik.it + DocumentRoot /usr/share/wordpress + DirectoryIndex index.php + Alias /wp-content/ "/srv/www/wp-content/{{ item }}.lilik.it/" + + AllowOverride All + Order Deny,Allow + Allow from all + + diff --git a/tasks/service.yaml b/tasks/service.yaml index 22056b1..7a964b6 100644 --- a/tasks/service.yaml +++ b/tasks/service.yaml @@ -1,6 +1,10 @@ --- - name: install {{ service_name }} - apt: name="{{ item }}" state=present + apt: + name: "{{ item }}" + state: present + update_cache: yes + cache_valid_time: 3600 with_items: "{{ service_packages }}" - name: start {{ service_name }} at boot service: name="{{ service_name }}" enabled=yes diff --git a/webmail.yaml b/webmail.yaml index 851d53e..d54ac9c 100644 --- a/webmail.yaml +++ b/webmail.yaml @@ -6,5 +6,5 @@ - hosts: webmail roles: - role: roundcube - imap_server: "{{ hostvars['mail'].ansible_host }}" - fqdn_domain: "lilik.it" + # imap_server: "{{ hostvars['mail'].ansible_host }}" + # fqdn_domain: "lilik.it"