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:
- Modular task execution for diverse infrastructure needs.
- Support for package, service, and file management.
- Advanced logging and error handling mechanisms.
- Integration with cloud platforms and container orchestration systems.
- Extensible architecture for custom workflows.
Use Cases:
- Automated server configuration.
- Kubernetes and Docker management.
- Storage, backup, and restore operations.
- Monitoring and logging setup.
- Security compliance and auditing.
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:
--file-path
: Path to the YAML configuration file.--ver, -v
: Path to an alternate variables file.--environment, -e
: Specify the environment (e.g., dev, test, prod).--show, -s
: Show sensitive variable values for debugging.--remote-ver, --rv
: URL to an alternate variables file.--password, -p
: Password for decrypting sensitive variables.--remote-config, --rc
: URL to a remote YAML config file.--set, -s
: Override variables from the command line in key=value format.
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:
podman_config
: Configuration dictionary for Podman management.private_ip
: IP address of the server.task_user
: The user executing the commands.summary
: Tracks task results.
Supported Actions:
state: started
- Starts a container.state: stopped
- Stops and removes a container.
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:
job_schedule_config
: Configuration for job scheduling.private_ip
: IP address of the server.task_user
: User executing the tasks.summary
: Tracks task results.
Supported Keys:
command
: Command to execute.when
: Time to schedule the command.
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:
plugin_config
: Configuration for plugin management.summary
: Tracks task results.
Sample Configuration:
plugin_management:
enabled: true
plugins:
- name: my_plugin
path: /path/to/plugin.zip
Steps:
- Validation: Validates the structure of the plugin zip file.
- Installation: Extracts and compiles the plugin.
- Storage: Stores the plugin in the designated directory.
12. Plugin Execution
Executes compiled plugins with specified parameters and dynamically loaded credentials.
Function: run_plugin_execution_steps
Arguments:
plugin_execution_config
: Configuration for plugin execution.summary
: Tracks task results.
Sample Configuration:
plugin_execution:
enabled: true
steps:
- plugin: my_plugin
provider: aws
parameters:
action: create
resource_type: ec2_instance
instance_type: t2.micro
Steps:
- Locate Plugin: Finds the plugin binary.
- Load Credentials: Loads cloud provider credentials (AWS, GCP, Azure).
- Execute Plugin: Runs the plugin with the specified parameters.
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