OtterShell Documentation

website·Indexed 30 days ago

https://ottershell.vercel.app/docs/category/tasks

A collection of technical guides and practical exercises covering system administration and DevOps tasks, including Kubernetes, Docker, Jenkins, OpenStack, Linux kernel compilation, and the configuration of LAMP/LEMP stacks, DNS (Bind9), and High Availability clusters.

Tokens
72.7K
Snippets
435
Records
470
Agent score
75%

What's inside OtterShell

  1. Configure Docker Compose for a PHP application with MariaDB

    This configuration defines a two-tier architecture: a PHP application container (bookmedik) and a MariaDB database container (bn-mariadb). The application depends on the database and uses environment variables for database connectivity and application credentials.
    version: '3.3'
    services:
      bn-mariadb:
        container_name: bn-mariadb
        image: mariadb
        restart: always
        environment:
          MARIADB_ROOT_PASSWORD: root
          MARIADB_DATABASE: bookmedik
          MARIADB_USER: admin
          MARIADB_PASSWORD: admin
        volumes:
          - mariadb_data:/var/lib/mysql
      bookmedik:
        container_name: bn-bookmedik
        image: belennazareth/bookmedik:v1_2
        restart: always
        environment:
          bookmedik_user: admin
          bookmedik_passwd: admin
          host_database: bn-mariadb
          db_name: bookmedik
        ports:
          - 8081:80
        depends_on:
          - bn-mariadb
    volumes:
        mariadb_data:
  2. Verify and inspect Kubernetes Deployment resources

    After applying a Deployment, you can verify the status of the Deployment, the automatically created ReplicaSets, and the resulting Pods using kubectl get. Detailed information about the Deployment's state and events can be retrieved using describe.
    # List resources
    kubectl get deployment
    kubectl get replicaset
    kubectl get pods
    
    # Get detailed information
    kubectl describe deployment test-web-deploy
  3. Design the OpenStack lab environment architecture

    The lab environment consists of four machines using a sub-domain format: tunombre.gonzalonazareno.org.

    • Machine 1 (alfa): OpenStack instance running Debian 11 Bullseye. Acts as the gateway for the internal network.
    • Machine 2 (bravo): OpenStack instance running Rocky Linux 9.
    • Machine 3 (charlie): LXC container running Ubuntu 20.04 (hosted on alfa).
    • Machine 4 (delta): LXC container running Ubuntu 20.04 (hosted on alfa).
  4. Identify CentOS migration alternatives

    Due to the end of support for CentOS 8 and the scheduled end-of-life for CentOS 7 (June 30, 2024), several alternative distributions are available for server migration:

    • Red Hat Solutions: Red Hat Enterprise Linux (RHEL), CentOS Stream.
    • Oracle Solution: Oracle Linux.
    • Community-driven/New Distributions: AlmaLinux, Rocky Linux, VZLinux, EuroLinux.
    • Other Linux Distributions: Debian, openSUSE, Slackware.
  5. Inspect package details with apt and aptitude

    Several commands can be used to retrieve information about a package regardless of whether it is installed:

    • apt show: Provides a general detailed description of the package.
    • apt-cache showpkg: Provides extensive information including reverse dependencies, versions, and descriptions.
    • aptitude show: Displays detailed information about a package candidate or installed version.
    apt show <package_name>
    apt-cache showpkg <package_name>
    aptitude show <package_name>
  6. Use Bind Mounts for host-to-container file sharing

    Bind mounts allow you to map a specific directory on the host machine to a directory in the container. This is useful for development as changes made to the host files are immediately reflected in the container.
    # Mount a specific host path (/home/debian/bindmount) to the container path
    docker run -d --name miweb -p 8080:80 -v /home/debian/bindmount:/var/www/html php:7.4-apache
  7. Install Docker Engine on Debian for Kubernetes

    Install Docker Engine and containerd on all cluster nodes (master and workers) to serve as the container runtime.
    # Update and install prerequisites
    sudo apt-get update
    sudo apt-get install ca-certificates curl gnupg
    
    # Add Docker GPG key
    sudo install -m 0755 -d /etc/apt/keyrings
    curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
    sudo chmod a+r /etc/apt/keyrings/docker.gpg
    
    # Add Docker repository
    echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    
    # Install Docker Engine and containerd
    sudo apt-get update
    sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
  8. Install and enable PHP-FPM on Apache2

    To configure Apache2 to use PHP-FPM, install the php-fpm package and enable the necessary proxy modules. You must disable the standard PHP module to ensure requests are handled by FPM.
    # Install PHP-FPM
    sudo apt install php-fpm
    
    # Enable proxy and environment modules
    a2enmod proxy_fcgi setenvif
    
    # Enable the PHP-FPM configuration (example for PHP 7.4)
    a2enconf php7.4-fpm
    
    # Restart Apache to apply changes
    systemctl restart apache2
    
    # Disable the standard PHP module to avoid conflicts
    a2dismod php7.4
    systemctl restart apache2
  9. Provision OpenStack instance using cloud-config.yaml

    Use a cloud-config.yaml file to automate the initial setup of an OpenStack instance. This configuration handles package updates, hostname/FQDN assignment, user creation with sudo privileges and SSH keys, and root password assignment.
    #cloud-config
    package_update: true
    package_upgrade: true
    
    hostname: alfa
    fqdn: alfa.gonzalonazareno.org
    
    users:
      - name: nazare
        sudo: ALL=(ALL) NOPASSWD:ALL
        shell: /bin/bash
        passwd: nazare
        ssh_authorized_keys:
          - ssh-rsa AAAAB3... [key] ... nazare@ThousandSunny
      - name: profesor
        sudo: ALL=(ALL) NOPASSWD:ALL
        shell: /bin/bash
        passwd: profesor
        ssh_authorized_keys:
          - ssh-rsa AAAAB3... [key] ... jose@debian
    
    chpasswd:
       list: |
           root:root
       expire: False
  10. Install and initialize ISC DHCP Server

    Install the isc-dhcp-server package. Note that the service will initially fail to start because it requires configuration before it can run successfully. Logs can be checked via /var/log/syslog or systemctl -u isc-dhcp-server.
    sudo apt-get install -y isc-dhcp-server
  11. Configure an iSCSI target on a Linux server using tgt

    To create an iSCSI target with a Logical Unit Number (LUN) on a Linux server, install the tgt package and define the target in the configuration file. The backing-store directive specifies the physical device to be shared as a LUN.
    # Edit /etc/tgt/targets.conf and add the target definition
    # Example: <target iqn.2023-01-target1>
    #     backing-store /dev/vdb
    # </target>
    
    # Restart the tgt service to apply changes
    sudo systemctl restart tgt
    
    # Verify the target and LUN creation
    sudo tgtadm --mode target --op show
  12. Install and basic setup of Postfix mail server on VPS

    To set up a basic mail server on a VPS, install Postfix for mail handling and bsd-mailx for sending emails from the command line. Ensure the server has a valid MX record (e.g., mail.yourdomain.com), port 25 is open in the firewall, and a reverse DNS entry is configured.
    # Install Postfix and mail utilities
    sudo apt install postfix bsd-mailx
    
    # Verify MX record
    dig MX yourdomain.com