InfraSet User Guide

InfraSet is a function designed to automate and manage complex infrastructure tasks. It supports dynamic configuration, real-time execution, and various management capabilities such as package management, service control, networking, and more.

Overview

Key Features:

Use Cases:

CLI Commands

Group Command: infraset

This group command serves as the entry point for all InfraSet-related operations.

Command: apply

Executes the main InfraSet process based on a YAML configuration file.

$ dob infraset apply --file-path <path_to_yaml> [options]

Options:

Example:

$ infraset apply --file-path config.yaml -e dev --show

Configuration Management

YAML Configuration File Structure

The configuration file defines the jobs, stages, and tasks for execution.


mode: remote
jobs:
  - name: "Job 1"
    stages:
      - name: "Setup Stage"
        tasks:
          setup_and_clone:
            enabled: true
            repo_url: "https://github.com/example/repo.git"

      - name: "Package Installation"
        tasks:
          package_management:
            enabled: true
            steps:
              - type: apt
                name: git
                state: present
      

Key Features and Tasks

1. Package Management

Manages installation and removal of software packages.

Supported types: apt, yum, dnf, zypper, brew, pip.

Example Configuration:


package_management:
  enabled: true
  steps:
    - type: apt
      name: nginx
      state: present
      

2. Service Management

Controls services on the target machine.

Actions: start, stop, restart, reload.

Example Configuration:


service_management:
  enabled: true
  steps:
    - name: nginx
      state: restarted
      

3. File and Directory Management

Handles file and directory creation, copying, and templating.

Example Configuration:


file_directory_management:
  enabled: true
  steps:
    - action: create
      path: /var/log/myapp
      state: directory
    - action: remote_copy
      src: /local/path/to/file
      dest: /remote/path/to/file
      

4. Networking Management

Configures firewall rules, network interfaces, and DNS settings.

Example Configuration:


network_management:
  enabled: true
  steps:
    - port: 8080
      protocol: tcp
      action: add
      

5. Storage Management

Manages storage devices, mounts, and logical volumes.

Example Configuration:


storage_management:
  enabled: true
  steps:
    - action: create_lv
      vg: myvg
      lv: mylv
      size: 10G
      src: /dev/sdb
      

6. System Configuration

Configures system settings such as hostname and sysctl parameters.

Example Configuration:


system_configuration:
  enabled: true
  steps:
    - action: sysctl
      name: net.ipv4.ip_forward
      value: 1
      

7. Cron Job Management

Creates and manages cron jobs.

Example Configuration:


cron_job:
  enabled: true
  steps:
    - name: "Daily Backup"
      local_path: /scripts/backup.sh
      job: /usr/local/bin/backup.sh
      minute: 0
      hour: 2
      

8. Security and Compliance

Manages security settings such as SELinux, auditd, and Fail2Ban.

Example Configuration:


security_compliance_management:
  enabled: true
  steps:
    - type: auditd_service
      params:
        name: auditd
        state: started
      

9. Podman Container Management

This function manages Podman containers by starting or stopping them as specified in the configuration.

Function: run_podman_container_steps

Arguments:

Supported Actions:

Sample Configuration:


podman:
  enabled: true
  steps:
    - name: my_container
      image: nginx:latest
      state: started
      

10. Job Scheduling

Schedules jobs using the at command for future execution.

Function: run_job_scheduling_steps

Arguments:

Supported Keys:

Sample Configuration:


job_scheduling:
  enabled: true
  steps:
    - command: "echo 'Hello World' >> /tmp/hello.txt"
      when: "now + 1 minute"
      

11. Plugin Management

Handles storing, validating, and compiling plugins.

Function: run_plugin_management_steps

Arguments:

Sample Configuration:


plugin_management:
  enabled: true
  plugins:
    - name: my_plugin
      path: /path/to/plugin.zip
      

Steps:

12. Plugin Execution

Executes compiled plugins with specified parameters and dynamically loaded credentials.

Function: run_plugin_execution_steps

Arguments:

Sample Configuration:


plugin_execution:
  enabled: true
  steps:
    - plugin: my_plugin
      provider: aws
      parameters:
        action: create
        resource_type: ec2_instance
        instance_type: t2.micro
      

Steps:

Examples

Podman Container Management

YAML Configuration:


podman:
  enabled: true
  steps:
    - name: web_server
      image: nginx:latest
      state: started
      

Job Scheduling

YAML Configuration:


job_scheduling:
  enabled: true
  steps:
    - command: "echo 'Job Scheduled' >> /tmp/job.txt"
      when: "12:00 PM"
      

Plugin Management

YAML Configuration:


plugin_management:
  enabled: true
  plugins:
    - name: example_plugin
      path: /path/to/example_plugin.zip
      

Plugin Execution

YAML Configuration:


plugin_execution:
  enabled: true
  steps:
    - plugin: example_plugin
      provider: aws
      parameters:
        action: delete
        resource_type: s3_bucket
        bucket_name: example_bucket