Open Source For You — December 2017

(Steven Felgate) #1
How To Admin

http://www.OpenSourceForU.com | OPEN SOURCE FOR YOU | DECEMBER 2017 | 41

tags: [piwigo]

vars:
piwigo_dest: “/var/www/html”

tasks:


  • name: Update the software package repository
    apt:
    update_cache: yes

  • name: Create a database for piwigo
    mysql_db:
    name: piwigo
    state: present

  • name: Create target directory
    file:
    path: “{{ piwigo_dest }}/gallery”
    state: directory

  • name: Download latest piwigo
    get_url:
    url: http://piwigo.org/download/dlcounter.
    php?code=latest
    dest: “{{ piwigo_dest }}/piwigo.zip”

  • name: Extract to /var/www/html/gallery
    unarchive:
    src: “{{ piwigo_dest }}/piwigo.zip”


dest: “{{ piwigo_dest }}/gallery”
remote_src: True


  • name: Restart apache2 server
    service:
    name: apache2
    state: restarted


The piwigo_dest variable stores the location of the
default Apache hosting directory. The APT software
package repository is then updated. Next, an exclusive
MySQL database is created for this Piwigo installation.
A target folder gallery is then created under /var/www/
html to store the Piwigo PHP files. Next, the latest
version of Piwigo is downloaded (2.9.2, as on date)
and extracted under the gallery folder. The Apache Web
server is then restarted.
You can invoke the above playbook as follows:

$ ansible-playbook -i inventory/kvm/inventory playbooks/
configuration/piwigo.yml --tags piwigo -K

If you open the URL http://192.168.122.4/gallery in a
browser on the host system, you will see the screenshot given
in Figure 2 to start the installation of Piwigo.
After entering the database credentials and creating an
admin user account, you should see the ‘success’ page, as
shown in Figure 3.
You can then go to http://192.168.122.4/gallery to see the
home page of Piwigo, as shown in Figure 4.

Backup
The Piwigo data is present in both the installation folder and
in the MySQL database. It is thus important to periodically
make backups, so that you can use these archive files to
restore data, if required. The following Ansible playbook
creates a target backup directory, makes a tarball of the
installation folder, and dumps the database contents to a
.sql file. The epoch timestamp is used in the filename. The
backup folder can be rsynced to a different system or to
secondary backup.


  • name: Backup Piwigo
    hosts: ubuntu
    become: yes


Figure 2: Piwigo install page


Figure 4: Piwigo home page

Figure 3: Piwigo install success page

Free download pdf