Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example deploying a LAMP Stack and provisioning with Ansible Role infamousjoeg.provisioning
---
- hosts: localhost
pre_tasks:
- name: Install Apache & PHP
yum:
name: ['httpd', 'php', 'php-mysql']
state: present
- name: Install Web Role Specific Dependencies
yum:
name: ['git', 'wget', 'curl', 'jq', 'libsemanage-python']
state: present
- name: Start Apache
service:
name: httpd
state: started
enabled: yes
- name: Configure SELinux to Allow httpd Connection to Remote Database
seboolean:
name: httpd_can_network_connect_db
state: true
persistent: yes
- name: Create index.php Start Page
copy:
dest: "/var/www/html/index.php"
content: |
<?php echo "Hello World!"; ?>
- name: Install MariaDB Package
yum:
name: ['mariadb-server', 'MySQL-python']
state: present
- name: Configure SELinux to Start MySQL on Any Port
seboolean:
name: mysql_connect_any
state: true
persistent: yes
- name: Start MySQL Service
service:
name: mariadb
state: started
enabled: yes
- name: Create a New Database
mysql_db:
name: demo
state: present
collation: utf8_general_ci
- name: Set Fact with Current Remote Machine Hostname
set_fact:
mysql_address: "{{ inventory_hostname }}"
- name: Set Fact with MySQL Database Username
set_fact:
mysql_username: demo
- name: Set Fact with Randomized Password for MySQL Database User
set_fact:
mysql_password: "{{ lookup('password', '/dev/null length=15 chars=ascii_letters') }}"
no_log: yes
- name: Create a Database User
mysql_user:
name: "{{ mysql_username }}"
password: "{{ mysql_password }}"
priv: "*.*:ALL"
host: localhost
state: present
- name: Copy sample data to local filesystem /tmp/
copy:
src: files/dump.sql
dest: /tmp/dump.sql
- name: Insert sample data into demo table in MySQL
shell: "mysql -u {{ mysql_username }} -p{{ mysql_password }} demo < /tmp/dump.sql"
- name: Restart Apache
service:
name: httpd
state: restarted
- name: Install Database Connection PHP Script db.php
copy:
src: files/db.php
dest: /var/www/html/db.php
roles:
- role: infamousjoeg.provisioning
cyberark_api_base_url: https://components.cyberarkdemo.example
cyberark_auth_type: LDAP
cyberark_validate_certs: no
cyberark_username: Svc_ProvTest_Fedora
cyberark_password: Cyberark1
cyberark_acct_name: TEST-AUTO-ONBOARD-{{ mysql_address }}-{{ mysql_username }}
cyberark_acct_address: "{{ mysql_address }}"
cyberark_acct_username: "{{ mysql_username }}"
cyberark_acct_password: "{{ mysql_password }}"
cyberark_acct_platformId: MySQL
cyberark_acct_safeName: TEST-AUTO-ONBOARD
cyberark_acct_secretType: password
cyberark_acct_autoManagement: no
cyberark_acct_manualReason: For demo purposes
@infamousjoeg

This comment has been minimized.

Copy link
Owner Author

commented May 8, 2019

asciicast

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.