Skip to main content

Deploy and set up LAMP stacks with Ansible

Project description

Lampsible

About

Complete LAMP stack setup, with a single CLI command. Powered by Ansible under the hood. This tool can automate almost anything that you'd expect from a LAMP stack.

Features

  • Out of the box LAMP stack
  • Custom Apache configuration (custom webroot, vhosts, etc.)
  • Apache or MySQL by itself
  • WordPress, including custom themes and plugins
  • Joomla
  • Drupal
  • Custom Laravel app
  • SuiteCRM
  • Production ready SSL via Certbot
  • SSL for test servers (to avoid being rate limited by Let's Encrypt)
  • Self signed SSL, good for local test networks
  • Custom PHP extensions, php.ini settings, phpMyAdmin, Composer packages, etc.
  • And so on...

Requirements

Depends on the use case.

If installing web app on remote host

This is the preferred way to use Lampsible.

  • Local: Unix system with Python 3.9 or newer. Tested on Ubuntu and Gentoo Linux. Might work on macOS, but I haven't tested that. Won't work on Windows, because Ansible requires a Unix like system.
  • Remote: Ubuntu 20 or newer, Ubuntu 24 or older. You need SSH access and root privilege, or ability to elevate privilege to root. Might work on older versions, but I doubt it. Support for other distros is planned in a future version.
    • Note for Ubuntu 25: It's currently not supported. Still waiting for support in some upstream dependencies. For now, please don't use a more recent version than Ubuntu 24.

Alternative: installing web app directly on localhost

Your machine should be similar to the "Remote" outlined above, Ubuntu Linux. Also, you need root access on that machine. Ideally, you'll run as a nonprivileged user, and be asked for the root password. Finally, if you run this way, this should not be some kind production server, but some local test server in a private network.

Installing

Pip

pip install lampsible

Alternative: from source

git clone https://github.com/belal-i/lampsible
cd lampsible
python3 -m pip install .

Usage

There are 2 ways to use Lampsible: as a CLI tool, or as a Python library.

CLI tool

Once you've installed Lampsible onto your local environment, you can run the lampsible command.

It takes the format: lampsible user@host ACTION [OPTIONS]

If you are running locally, you can simply do: lampsible localhost ACTION [OPTIONS]

It is designed to be very simple to use. If you omit some important parameter, like admin user, password, site title, etc, you will be prompted to enter a value, or fall back to a default.

Below are some examples:

  • Install a production ready WordPress site:

    lampsible someuser@somehost.com wordpress \
        --email-for-ssl you@yourdomain.com
    
  • Install a production ready WooCommerce shop with some other plugins and a custom theme:

    lampsible someuser@somehost.com wordpress \
        --email-for-ssl you@yourdomain.com \
        --wordpress-plugins woocommerce,wordpress-seo,akismet,wordfence \
        --wordpress-theme frutiger-aero
    
  • Install a production ready Joomla site:

    lampsible someuser@somehost.com joomla \
        --email-for-ssl you@yourdomain.com
    
  • Install Drupal on a test server. Certbot will set up a test certificate. Also, Apache and MySQL will run on two separate hosts.

    lampsible someuser@somehost.com drupal \
        --database-system-user-host otheruser@dbserver.somehost.com \
        --database-host 10.0.1.2 \
        --database-username dbuser
        --ssl-test-cert \
        --apache-server-admin you@yourdomain.com \
    
  • Set up a LAMP stack with various custom configuration and a self signed SSL certificate on some local VM:

    lampsible someuser@192.168.123.123 lamp-stack \
        --ask-remote-sudo \
        --ssl-selfsigned \
        --database-username dbuser \
        --database-name testdb \
        --apache-vhost-name some-legacy-app \
        --apache-document-root /var/www/html/some-legacy-app/some-dir/public \
        --php-extensions mysql,xml,mbstring,xdebug,gd
    

Run lampsible --help for a full list of options.

Python library

Lampsible can be used as a Python library, so if you want to build your own tool, and want to leverage Lampsible's features to automate various Apache webserver setups, you can do that.

It could look something like this:

# my_automation_tool.py

from lampsible.lampsible import Lampsible

# Simple WordPress setup
lampsible = Lampsible(
    web_user='someuser',
    web_host='somehost.example.com',
    action='wordpress',
    # Required for Certbot. You can also use email_for_ssl
    apache_server_admin='someuser@example.com',
    database_name='wordpress',
    database_username='db-user',
    database_password='topsecret',
    admin_username='your-wordpress-admin',
    admin_email='wp-admin@example.com',
    admin_password='anothertopsecret',
    site_title='My WordPress Blog',
    wordpress_plugins=[
        'akismet',
        'wordpress-seo',
        'wordfence',
    ],
    # Set this to give your consent to install some required
    # Ansible Galaxy Collections. Otherwise, if any of them are missing,
    # Lampsible will throw an error. If those collections are already installed,
    # this attribute is no longer required.
    # See /src/lampsible/project/ansible-galaxy-requirements.yml
    ansible_galaxy_ok=True,
)

result = lampsible.run()


# Joomla setup. This example is a little more complex,
# to showcase some more features. Webserver and
# database server are two different hosts,
# a database root password will be set.
# Certbot will run with the --test-cert flag,
# an older version of Joomla will be installed,
# some custom PHP extensions will be installed
# alongside the ones required by Joomla,
# and some extra environment variables will be set.
lampsible = Lampsible(
    web_user='someuser',
    web_host='somehost.example.com',
    # This assumes that you want your database server
    # to be reachable from the outside via the
    # domain dbserver.example.com, and within your
    # internal network, including your Joomla webserver,
    # via the private IP address 10.0.1.2.
    database_system_user='root',
    database_system_host='dbserver.example.com',
    database_host='10.0.1.2',
    action='joomla',
    email_for_ssl='someuser@example.com',
    ssl_test_cert=True,
    database_name='joomla',
    database_username='db-user',
    database_password='topsecret',
    database_root_password='supertopsecret',
    admin_username='your-joomla-admin',
    admin_email='joomla-admin@example.com',
    admin_password='anothertopsecret',
    # These extensions will be appended to the list of
    # extensions required by the system you are
    # installing (in this case Joomla).
    php_extensions=['php-curl', 'php-gd'],
    joomla_admin_full_name='Your Name',
    joomla_version='5.1.4',
    site_title='My Joomla Site',
    extra_env_vars={'FOO': 'bar', 'HELLO': 'world'}
)

result = lampsible.run()

FAQ

  • Why not just use Docker?

Lampsible is intended to be an homage to the old school: A simple and versatile LAMP stack. If you want something similar with Docker, consider using Docksible, another project that I maintain. It will install a web app onto your remote server with Docker Compose. It also leverages Ansible locally under the hood.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lampsible-2.5.2.tar.gz (46.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lampsible-2.5.2-py3-none-any.whl (50.6 kB view details)

Uploaded Python 3

File details

Details for the file lampsible-2.5.2.tar.gz.

File metadata

  • Download URL: lampsible-2.5.2.tar.gz
  • Upload date:
  • Size: 46.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for lampsible-2.5.2.tar.gz
Algorithm Hash digest
SHA256 2c491a370e753911691d6f7fa99c282c8d4c94f85e1e3e217063a43adbb2e657
MD5 c368ac5aeb58c4ce74e40fe1c70a8220
BLAKE2b-256 035fb2a832f3f49445b19dc739f72c2a5402c5421f56f90e46d73f39e471c5d7

See more details on using hashes here.

File details

Details for the file lampsible-2.5.2-py3-none-any.whl.

File metadata

  • Download URL: lampsible-2.5.2-py3-none-any.whl
  • Upload date:
  • Size: 50.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for lampsible-2.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8a33b516e17621acb5d4aa9fc3b8b35e4c225063d3397865b2a1452243e4e018
MD5 eeb38e0adbb920c6442ecc046fbd60ac
BLAKE2b-256 1e567c2ed03591120f513a13c1c336379e4f42168a1b0254a5c43624aa77eef7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page