Ansible for SAP: Automate SAP HANA and S/4HANA Deployment, Configuration, and Operations
By Luca Berton · Published 2024-01-01 · Category: installation
Automate SAP infrastructure with Ansible. Deploy SAP HANA, configure S/4HANA, manage SAP Basis operations, automate system copies, kernel updates, and transport management using Red Hat certified SAP collections.
Why Automate SAP with Ansible?
SAP environments are complex — HANA databases, application servers, ASCS instances, web dispatchers, routers, and dozens of configuration files across multiple tiers. A typical S/4HANA landscape has development, quality, and production systems, each requiring identical but parameterized configurations.
Manual SAP administration is slow, error-prone, and doesn't scale. Ansible brings: • Consistent deployments — same playbook deploys SAP identically across landscapes • Faster system copies — automate the 40+ step refresh process • Compliant operations — every change is auditable, versioned, repeatable • Reduced Basis workload — automate kernel updates, transport imports, monitoring setup
SAP Ansible Collections
community.sap_install
The primary collection for SAP infrastructure and installation:
Roles included:
| Role | Purpose | |------|---------| | sap_general_preconditions | OS prerequisites (packages, kernel params, limits) | | sap_hana_install | SAP HANA database installation | | sap_hana_preconfigure | HANA-specific OS tuning | | sap_netweaver_preconfigure | NetWeaver/S4HANA OS tuning | | sap_swpm | SAP Software Provisioning Manager execution | | sap_ha_install_hana_hsr | HANA System Replication setup | | sap_ha_pacemaker_cluster | High availability cluster configuration | | sap_hostagent | SAP Host Agent installation | | sap_storage_setup | Disk layout for SAP (LVM, filesystem, mount) |
community.sap_operations
Day-2 operations for running SAP systems:
Modules:
| Module | Purpose | |--------|---------| | sap_system_facts | Gather SAP system information | | sap_control_exec | Execute sapcontrol commands | | sap_hdbsql | Run HANA SQL statements | | sap_task_list_execute | Execute SAP task lists | | sap_pyrfc | SAP RFC function calls via PyRFC |
community.sap_libs
SAP-specific library functions and filters.
Prepare Infrastructure for SAP
OS Prerequisites
This handles: • Required packages (compat-sap-c++, libtool-ltdl, resource-agents) • Kernel parameters (vm.memory_failure_early_kill, vm.max_map_count) • System limits (nofile, nproc, memlock) • tmpfs sizing • SELinux configuration • NUMA balancing • Transparent Huge Pages (disabled for HANA)
Storage Layout
Install SAP HANA
HANA System Replication
Install S/4HANA
Day-2 Operations
Start and Stop SAP Systems
HANA Database Operations
SAP Kernel Update
Transport Management
Cloud Deployment with Ansible
SAP on AWS
SAP on Azure
Integration with AAP
For enterprise SAP automation, use AAP (Automation Controller) with: • Workflow templates — chain infrastructure provisioning → OS prep → HANA install → app install → post-config • Surveys — prompt operators for SID, instance numbers, landscape (DEV/QAS/PRD) • RBAC — SAP Basis team can run operations playbooks, only admins can run installations • Schedules — automated nightly HANA backups, weekly health checks • Credentials — vault-encrypted SAP passwords, SSH keys, cloud credentials • Notifications — Slack/Teams/email alerts on job success/failure
FAQ
Does Red Hat certify Ansible for SAP?
Yes. Red Hat and SAP jointly certify the SAP automation collections for production use. The community.sap_install collection is maintained by Red Hat's SAP team. RHEL for SAP Solutions includes specific OS tuning and extended support.
Can Ansible replace SAP LaMa (Landscape Management)?
Ansible can automate many tasks that LaMa handles (system copies, start/stop, monitoring), but LaMa provides SAP-specific workflow orchestration and a purpose-built UI for SAP administrators. They complement each other — use Ansible for infrastructure and OS-level automation, LaMa for SAP application lifecycle.
How do I handle SAP system copies with Ansible?
Automate the full refresh cycle: stop target system → HANA backup on source → HANA restore on target → post-copy processing (client changes, user unlocks, RFC destination updates, transport buffer cleanup, printer config) → start target system. The community.sap_operations collection provides the building blocks.
Conclusion
Ansible with the SAP collections automates the entire SAP lifecycle — from infrastructure provisioning and HANA installation through S/4HANA deployment to ongoing operations like kernel updates, transport management, and system copies. Combined with AAP, it provides enterprise-grade SAP automation with RBAC, scheduling, and audit trails that SAP Basis teams need.
Related Articles • AAP 2.6 Architecture and Components • AAP 2.6 Workflow Templates: Advanced Pipeline Automation • AAP 2.6 Credential Management: Vault, CyberArk, HashiCorp • AAP 2.6 Job Scheduling and Capacity Planning • Ansible for Cloud Automation: AWS, Azure, GCP
Category: installation