Skip to content

Commit

Permalink
namespace role vars
Browse files Browse the repository at this point in the history
  • Loading branch information
ellotheth committed Jan 27, 2014
1 parent b084f6d commit 09b53b9
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 84 deletions.
44 changes: 22 additions & 22 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,68 +3,68 @@
# defaults for oracle installation

# to be added to /etc/hosts
db_hostname: oracle
oracle_hostname: oracle

# location for temporary installation files
install_temp: /tmp/oracle
oracle_tmp: /tmp/oracle

#
# oracle connection settings
#

# ORACLE_BASE parent, {{ ora_path }}/oracle
ora_path: /opt/oracle_app
# ORACLE_BASE parent, {{ oracle_path }}/oracle
oracle_path: /opt/oracle_app

# ORACLE_SID
db_name: db
oracle_db_name: db

# ORACLE_HOME basename, {{ ora_path }}/oracle/product/11.2.0/{{ db_home }}
db_home: db_home
# ORACLE_HOME basename, {{ oracle_path }}/oracle/product/11.2.0/{{ oracle_db_home }}
oracle_db_home: oracle_db_home

# initial db user
db_user: oracle
oracle_db_user: oracle

# password for the initial db user
db_pass: OracleUs3r
oracle_db_pass: OracleUs3r

# password for the sysdba
db_syspass: Oracle4dmin
oracle_db_syspass: Oracle4dmin

# system memory to allocate to the db server (40% total memory)
db_mem: "{{ ( ansible_memtotal_mb * 10 ) // 25 }}"
oracle_db_mem: "{{ ( ansible_memtotal_mb * 10 ) // 25 }}"

#
# oracle system user
#

# oracle user username
ora_user: oracle
oracle_user: oracle

# hashed password for the oracle user
# python -c 'import crypt; print crypt.crypt("oracle", "$1$salt$")'
ora_pass: $1$salt$6hY7SFGTovD5BRJ.4zYAd1
oracle_pass: $1$salt$6hY7SFGTovD5BRJ.4zYAd1

# primary oracle group
ora_group: oinstall
oracle_group: oinstall

# DBA group
dba_group: dba
oracle_dba_group: dba

#
# oracle installer archives
#

# if you need to download the installer files, set the URI here
ora_installer_uri: http://oracle.installer.host
oracle_installer_uri: http://oracle.installer.host

# official oracle installer archives
# source: http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-linx8664soft-100572.html
#
# - if you already have these files, stick them at {{ install_temp }}. ansible
# - if you already have these files, stick them at {{ oracle_tmp }}. ansible
# will automatically skip the downloading step.
# - if you've already extracted everything, set the vars below to false. your
# extracted installer directory should be {{ install_temp }}/database.
installer1: linux.x64_11gR2_database_1of2.zip
installer2: linux.x64_11gR2_database_2of2.zip
checksum1: 3152418844
checksum2: 3669256139
# extracted installer directory should be {{ oracle_tmp }}/database.
oracle_installer1: linux.x64_11gR2_database_1of2.zip
oracle_installer2: linux.x64_11gR2_database_2of2.zip
oracle_checksum1: 3152418844
oracle_checksum2: 3669256139
14 changes: 7 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ commented.
- name: set up an oracle database
sudo: yes
vars:
ora_path: /u01/app # ORACLE_BASE will be /u01/app/oracle
db_name: my_special_db # ORACLE_SID will be my_special_db
db_home: special_home # ORACLE_HOME will be /u01/app/oracle/product/11.2.0/special_home
db_user: devuser
db_pass: AnAwesomeAndAmazingP4ssw0rd
db_syspass: AMor3AwesomeAndAmazingP4ssw0rd
ora_installer_uri: http://my.host # Ansible will download http://my.host/linux.x64_11gR2_database_1of2.zip
oracle_path: /u01/app # ORACLE_BASE will be /u01/app/oracle
oracle_db_name: my_special_db # ORACLE_SID will be my_special_db
oracle_db_home: special_home # ORACLE_HOME will be /u01/app/oracle/product/11.2.0/special_home
oracle_db_user: devuser
oracle_db_pass: AnAwesomeAndAmazingP4ssw0rd
oracle_db_syspass: AMor3AwesomeAndAmazingP4ssw0rd
oracle_installer_uri: http://my.host # Ansible will download http://my.host/linux.x64_11gR2_database_1of2.zip
roles:
# more roles here
- oracle
Expand Down
8 changes: 4 additions & 4 deletions tasks/get_installer.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
- name: get oracle installer
get_url:
url: "{{ ora_installer_uri }}/{{ installer }}"
dest: "{{ install_temp }}/{{ installer }}"
url: "{{ oracle_installer_uri }}/{{ installer }}"
dest: "{{ oracle_tmp }}/{{ installer }}"

- name: verify installer checksum
command: cksum {{ install_temp }}/{{ installer }}
command: cksum {{ oracle_tmp }}/{{ installer }}
register: installer_check
failed_when: "installer_check.stdout.find('{{ checksum }}') != 0"

- name: unzip installer
unarchive: src={{ install_temp }}/{{ installer }} dest={{ install_temp }}
unarchive: src={{ oracle_tmp }}/{{ installer }} dest={{ oracle_tmp }}
72 changes: 36 additions & 36 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@
#

- include: get_installer.yml
when: installer1 != false
when: oracle_installer1 != false
vars:
installer: "{{ installer1 }}"
checksum: "{{ checksum1 }}"
installer: "{{ oracle_installer1 }}"
checksum: "{{ oracle_checksum1 }}"

- include: get_installer.yml
when: installer2 != false
when: oracle_installer2 != false
vars:
installer: "{{ installer2 }}"
checksum: "{{ checksum2 }}"
installer: "{{ oracle_installer2 }}"
checksum: "{{ oracle_checksum2 }}"

- name: make sure the installer directory exists
stat: path={{ install_temp }}/database
stat: path={{ oracle_tmp }}/database
register: install_dir
failed_when: not install_dir.stat.exists or not install_dir.stat.isdir

Expand All @@ -76,7 +76,7 @@
state: present
line: "127.0.0.1 {{ item }}"
with_items:
- "{{ db_hostname }}"
- "{{ oracle_hostname }}"
- "{{ ansible_hostname }}"

- name: oracle-recommended sysctl
Expand Down Expand Up @@ -132,37 +132,37 @@
- name: create initial groups for the oracle user
group: name={{ item }} state=present
with_items:
- "{{ ora_group }}"
- "{{ dba_group }}"
- "{{ oracle_group }}"
- "{{ oracle_dba_group }}"

- name: create oracle user
user:
name: "{{ ora_user }}"
group: "{{ ora_group }}"
groups: "{{ dba_group }}"
home: /home/{{ ora_user }}
name: "{{ oracle_user }}"
group: "{{ oracle_group }}"
groups: "{{ oracle_dba_group }}"
home: /home/{{ oracle_user }}
shell: /bin/bash
password: "{{ ora_pass }}"
password: "{{ oracle_pass }}"
append: yes

- name: create the oracle installation path
file:
mode: 0755
path: "{{ ora_path }}"
path: "{{ oracle_path }}"
state: directory
group: "{{ ora_group }}"
owner: "{{ ora_user }}"
group: "{{ oracle_group }}"
owner: "{{ oracle_user }}"

- name: chown the oracle installer directory to the oracle user
file:
group: "{{ ora_group }}"
owner: "{{ ora_user }}"
path: "{{ install_temp }}/database"
group: "{{ oracle_group }}"
owner: "{{ oracle_user }}"
path: "{{ oracle_tmp }}/database"
state: directory
recurse: yes

- name: set oracle user environment
lineinfile: dest=/home/{{ ora_user }}/.bashrc state=present line="{{ item }}"
lineinfile: dest=/home/{{ oracle_user }}/.bashrc state=present line="{{ item }}"
with_items:
- "export ORACLE_BASE={{ ora_user_env.ORACLE_BASE }}"
- "export ORACLE_SID={{ ora_user_env.ORACLE_SID }}"
Expand All @@ -182,26 +182,26 @@
- name: compose the oracle automated installer settings
template:
src: db_install.rsp.j2
dest: "{{ install_temp }}/db_install.rsp"
owner: "{{ ora_user }}"
group: "{{ ora_group }}"
dest: "{{ oracle_tmp }}/db_install.rsp"
owner: "{{ oracle_user }}"
group: "{{ oracle_group }}"

- name: install oracle
sudo_user: "{{ ora_user }}"
sudo_user: "{{ oracle_user }}"
environment: ora_user_env
command: "{{ install_temp }}/database/runInstaller -silent -force -ignoreSysPrereqs -responseFile {{ install_temp }}/db_install.rsp"
command: "{{ oracle_tmp }}/database/runInstaller -silent -force -ignoreSysPrereqs -responseFile {{ oracle_tmp }}/db_install.rsp"
when: not oracle_installed.stat.exists

- name: general oracle post-installation
command: "{{ ora_path }}/oraInventory/orainstRoot.sh"
command: "{{ oracle_path }}/oraInventory/orainstRoot.sh"
when: not oracle_installed.stat.exists

- name: db-specific oracle post-installation
command: "{{ ora_user_env.ORACLE_HOME }}/root.sh"
when: not oracle_installed.stat.exists

- name: turn off the enterprise manager web console
sudo_user: "{{ ora_user }}"
sudo_user: "{{ oracle_user }}"
environment: ora_user_env
command: "{{ ora_user_env.ORACLE_HOME }}/bin/emctl stop dbconsole"
ignore_errors: yes
Expand All @@ -210,8 +210,8 @@
lineinfile:
dest: /etc/oratab
state: present
regexp: "^{{ db_name }}"
line: "{{ db_name }}:{{ ora_user_env.ORACLE_HOME }}:Y"
regexp: "^{{ oracle_db_name }}"
line: "{{ oracle_db_name }}:{{ ora_user_env.ORACLE_HOME }}:Y"

- name: compose the oracle init.d script
template: src=oracle_init.j2 dest=/etc/init.d/oracle mode=0755
Expand All @@ -222,12 +222,12 @@
- name: compose the oracle user creation script
template:
src: sqlplus_user_setup.sh.j2
dest: "{{ install_temp }}/sqlplus_user_setup.sh"
dest: "{{ oracle_tmp }}/sqlplus_user_setup.sh"
mode: 0755
owner: "{{ ora_user }}"
group: "{{ ora_group }}"
owner: "{{ oracle_user }}"
group: "{{ oracle_group }}"

- name: create the oracle db user
sudo_user: "{{ ora_user }}"
sudo_user: "{{ oracle_user }}"
environment: ora_user_env
command: "{{ install_temp }}/sqlplus_user_setup.sh"
command: "{{ oracle_tmp }}/sqlplus_user_setup.sh"
16 changes: 8 additions & 8 deletions templates/db_install.rsp.j2
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_AND_CONFIG
ORACLE_HOSTNAME={{ ansible_hostname }}
UNIX_GROUP_NAME={{ ora_group }}
INVENTORY_LOCATION={{ ora_path }}/oraInventory
UNIX_GROUP_NAME={{ oracle_group }}
INVENTORY_LOCATION={{ oracle_path }}/oraInventory
SELECTED_LANGUAGES=en
ORACLE_HOME={{ ora_user_env.ORACLE_HOME }}
ORACLE_BASE={{ ora_user_env.ORACLE_BASE }}
oracle.install.db.InstallEdition=SEONE
oracle.install.db.isCustomInstall=false
oracle.install.db.customComponents=
oracle.install.db.DBA_GROUP={{ dba_group }}
oracle.install.db.OPER_GROUP={{ dba_group }}
oracle.install.db.DBA_GROUP={{ oracle_dba_group }}
oracle.install.db.OPER_GROUP={{ oracle_dba_group }}
oracle.install.db.CLUSTER_NODES=
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName={{ db_name }}
oracle.install.db.config.starterdb.SID={{ db_name }}
oracle.install.db.config.starterdb.globalDBName={{ oracle_db_name }}
oracle.install.db.config.starterdb.SID={{ oracle_db_name }}
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryLimit={{ db_mem }}
oracle.install.db.config.starterdb.memoryLimit={{ oracle_db_mem }}
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL={{ db_syspass }}
oracle.install.db.config.starterdb.password.ALL={{ oracle_db_syspass }}
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.SYSMAN=
Expand Down
2 changes: 1 addition & 1 deletion templates/oracle_init.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

LOCKFILE=/var/lock/subsys/oracle
ORACLE_HOME={{ ora_user_env.ORACLE_HOME }}
ORACLE_USER={{ ora_user }}
ORACLE_USER={{ oracle_user }}

case "$1" in
'start')
Expand Down
6 changes: 3 additions & 3 deletions templates/sqlplus_user_setup.sh.j2
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/sh

source /home/{{ ora_user }}/.bashrc
source /home/{{ oracle_user }}/.bashrc

sqlplus / as sysdba <<EOT
CREATE USER {{ db_user }} IDENTIFIED BY {{ db_pass }};
GRANT connect, resource TO {{ db_user }};
CREATE USER {{ oracle_db_user }} IDENTIFIED BY {{ oracle_db_pass }};
GRANT connect, resource TO {{ oracle_db_user }};
exit;
EOT
6 changes: 3 additions & 3 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# shell environment for the oracle user
ora_user_env:
ORACLE_BASE: "{{ ora_path }}/oracle"
ORACLE_SID: "{{ db_name }}"
ORACLE_HOME: "{{ ora_path }}/oracle/product/11.2.0/{{ db_home }}"
ORACLE_BASE: "{{ oracle_path }}/oracle"
ORACLE_SID: "{{ oracle_db_name }}"
ORACLE_HOME: "{{ oracle_path }}/oracle/product/11.2.0/{{ oracle_db_home }}"
NLS_LANG: "American_America.UTF8"

0 comments on commit 09b53b9

Please sign in to comment.