1_ssh-copy-id.yml
---
- hosts: all
tasks:
- name: deliver id_rsa.pub to client
authorized_key:
user: "root"
key: "{{ lookup('file', '/root/.ssh/id_rsa.pub') }}"
state: present
exclusive: no
2_download.yml
---
- hosts: master
tasks:
- name: download mysql-connector-java-5.1.47.tar.gz to /root/
get_url:
url: "https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.47.tar.gz"
dest: "/root/"
force: yes
- name: download manifest.json to /root/
get_url:
url: "http://archive.cloudera.com/cdh5/parcels/latest/manifest.json"
dest: "/root/"
force: yes
- name: download CDH-5.16.1-1.cdh5.16.1.p0.3-el7.parcel.sha1 to /root/
get_url:
url: "http://archive.cloudera.com/cdh5/parcels/latest/CDH-5.16.1-1.cdh5.16.1.p0.3-el7.parcel.sha1"
dest: "/root/"
force: yes
3_copy.yml
---
- hosts: client
tasks:
- name: copy /etc/hosts to client hosts
copy:
src: "/etc/hosts"
dest: "/etc/hosts"
force: yes
backup: yes
4_install-java.yml
---
- hosts: all
tasks:
- name: install open jdk by yum
yum:
name: "java-1.8.0-openjdk"
state: present
- name: mkdir /usr/java/
file:
path: "/usr/java/"
state: directory
- name: config soft link to java home
file:
src: "/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64"
path: "/usr/java/latest"
state: link
- name: config JAVA_HOME to /etc/environment
lineinfile:
line: "JAVA_HOME=/usr/java/latest/jre"
path: "/etc/environment"
insertafter: EOF
5_sys_config.yml
---
- hosts: all
tasks:
- name: config nproc memlock
lineinfile:
line: "* soft nproc 65535\n* hard nproc 65535\n* soft memlock unlimited\n* hard memlock unlimited"
path: "/etc/security/limits.conf"
insertafter: EOF
- name: set transparenent_hugepage/defrag to never
shell: "echo never > /sys/kernel/mm/transparent_hugepage/defrag;"
- name: set transparenent_hugepage/enabled to never
shell: "echo never > /sys/kernel/mm/transparent_hugepage/enabled;"
- name: config nproc memlock
lineinfile:
line: "echo never > /sys/kernel/mm/transparent_hugepage/defrag\necho never > /sys/kernel/mm/transparent_hugepage/enabled"
path: "/etc/rc.local"
insertafter: EOF
6_install-mariadb.yml
---
- hosts: master
tasks:
- name: install mariadb-server by yum
yum:
name: "mariadb-server"
state: present
- name: install mariadb by yum
yum:
name: "mariadb"
state: present
- name: config server utf8 charset
lineinfile:
line: "character-set-server = utf8 "
path: "/etc/my.cnf"
insertafter: "\\[mysqld\\]"
- name: config client utf8 charset
lineinfile:
line: "default-character-set = utf8"
path: "/etc/my.cnf.d/client.cnf"
insertafter: "\\[client\\]"
- name: config mysql client user
lineinfile:
line: "user=root"
path: "/etc/my.cnf.d/client.cnf"
insertafter: "\\[client\\]"
- name: config mysql client password
lineinfile:
line: "password=''"
path: "/etc/my.cnf.d/client.cnf"
insertafter: "\\[client\\]"
- name: start mariadb-server
service:
name: "mariadb"
state: started
- name: alter password
shell: "/usr/bin/mysql -e 'set password = password(\"123123\")' "
- name: config mysql client password again
lineinfile:
line: "password='123123'"
path: "/etc/my.cnf.d/client.cnf"
regexp: "password=''"
- name: create databases
shell: "/usr/bin/mysql -e 'create database hive DEFAULT CHARSET utf8 COLLATE utf8_general_ci ;'"
- name: create databases
shell: "/usr/bin/mysql -e 'create database amon DEFAULT CHARSET utf8 COLLATE utf8_general_ci ;'"
- name: create databases
shell: "/usr/bin/mysql -e 'create database hue DEFAULT CHARSET utf8 COLLATE utf8_general_ci ;'"
- name: create databases
shell: "/usr/bin/mysql -e 'create database oozie DEFAULT CHARSET utf8 COLLATE utf8_general_ci ;'"
7_install-cm.yml
---
- hosts: client
tasks:
- name: copy cloudera-manager-centos7-cm5.16.1_x86_64.tar.gz to client hosts
copy:
src: "/root/cloudera-manager-centos7-cm5.16.1_x86_64.tar.gz"
dest: "/root/cloudera-manager-centos7-cm5.16.1_x86_64.tar.gz"
force: yes
- hosts: all
tasks:
- name: unarchive cloudera-manager-centos7-cm5.16.1_x86_64.tar.gz to /opt/
unarchive:
copy: no
src: "/root/cloudera-manager-centos7-cm5.16.1_x86_64.tar.gz"
dest: "/opt/"
- hosts: master
tasks:
- name: unarchive mysql-connector-java-5.1.47.tar.gz
unarchive:
copy: no
src: "/root/mysql-connector-java-5.1.47.tar.gz"
dest: "/root/"
- hosts: master
tasks:
- name: copy mysql-connector-java-5.1.47-bin.jar to /opt/cm-5.16.1/share/cmf/lib/
copy:
src: "/root/mysql-connector-java-5.1.47/mysql-connector-java-5.1.47-bin.jar"
dest: "/opt/cm-5.16.1/share/cmf/lib/"
force: yes
- hosts: master
tasks:
- name: initialize mysql database
shell: "/opt/cm-5.16.1/share/cmf/schema/scm_prepare_database.sh mysql cm -hlocalhost -uroot -p123123 --scm-host localhost scm scm scm"
- hosts: all
tags: config
tasks:
- name: modifiy config.ini and set server_host=cdh-master
lineinfile:
line: "server_host=cdh-master"
path: "/opt/cm-5.16.1/etc/cloudera-scm-agent/config.ini"
regexp: 'server_host=localhost'
8_add-user.yml
---
- hosts: all
tasks:
- name: add cm runtime user
user:
name: 'cloudera-scm'
create_home: no
system: yes
state: 'present'
comment: 'Cloudera SCM User'
shell: '/bin/false'
9_move-files.yml
---
- hosts: master
tasks:
- name: mv /root/CDH-5.16.1-1.cdh5.16.1.p0.3-el7.parcel /opt/cloudera/parcel-repo/
command: "mv /root/CDH-5.16.1-1.cdh5.16.1.p0.3-el7.parcel /opt/cloudera/parcel-repo/"
- name: rename sha1 to sha
command: "mv /root/CDH-5.16.1-1.cdh5.16.1.p0.3-el7.parcel.sha1 /opt/cloudera/parcel-repo/CDH-5.16.1-1.cdh5.16.1.p0.3-el7.parcel.sha"
- name: mv /root/manifest.json /opt/cloudera/parcel-repo/manifest.json
command: "mv /root/manifest.json /opt/cloudera/parcel-repo/manifest.json"
10_start-all.yml
---
- hosts: master
tasks:
- name: start server on master
command: "/opt/cm-5.16.1/etc/init.d/cloudera-scm-server start"
- hosts: client
tasks:
- name: start client on clients
command: "/opt/cm-5.16.1/etc/init.d/cloudera-scm-agent start"
- hosts: master
tags: port
tasks:
- name: wait until the web port is up
wait_for:
host: 0.0.0.0
port: 7180
state: started
main.yml
---
- include: 1_ssh-copy-id.yml
- include: 2_download.yml
- include: 3_copy.yml
- include: 4_install-java.yml
- include: 5_sys_config.yml
- include: 6_install-mariadb.yml
- include: 7_install-cm.yml
- include: 8_add-user.yml
- include: 9_move-files.yml
- include: 10_start-all.yml