Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- # this file is for instlaling DB
- - hosts: rancher
- remote_user: ansible
- become: yes
- become_method: sudo
- connection: ssh
- vars:
- my_sql_root_pass: P@ssw0rd.1.123
- tasks:
- - name: Install Mysql
- apt: name={{item}} state=installed update_cache=true
- with_items:
- - mysql-server
- - python-mysqldb
- - build-essential
- - python-pip
- - libmysqlclient-dev
- - python-dev
- - name: install mysql-python using pip
- pip: name={{item}} state=present
- with_items:
- - pip
- - MySQL-python
- - name: Start mysql service
- service: name=mysql.service state=started enabled=true
- - name: copy the root credentials as .my.cnf file
- template: src=root.cnf.j2 dest=/root/.my.cnf mode=0600
- - name: update mysql root password
- mysql_user: name=root host={{ item }} password={{ my_sql_root_pass }} priv=*.*:ALL,GRANT
- with_items:
- - "{{ ansible_hostname }}"
- - 127.0.0.1
- - ::1
- - localhost
- - name: create a new DB
- mysql_db: name=cattle
- collation=utf8_general_ci
- encoding=utf8
- state=present
- - name: create a new DB user
- mysql_user: name=cattle
- password=P@ssw0rd.1.123
- priv="cattle.*:ALL,GRANT"
- host=localhost
- state=present
- - name: restart mysql
- service: name=mysqld state=restarted
Add Comment
Please, Sign In to add comment