Skip to content

Instantly share code, notes, and snippets.

@agowa
Forked from ostcar/inyoka_dev.yml
Last active October 13, 2017 00:57
Show Gist options
  • Save agowa/c0c01c44754a962ad69372bc46049f82 to your computer and use it in GitHub Desktop.
Save agowa/c0c01c44754a962ad69372bc46049f82 to your computer and use it in GitHub Desktop.
ansible config for mysql and redis
---
- hosts: mariadb_dev
vars:
mysql_root_pw: ''
tasks:
- name: enable network
service:
name: '{{ item }}'
state: started
enabled: yes
with_items:
- systemd-networkd
- systemd-resolved
- name: create symlink for /etc/resolve.conf
file:
path: /etc/resolv.conf
state: link
src: /run/systemd/resolve/resolv.conf
force: yes
- name: Upgrade pacman pacage cache
pacman:
update_cache: yes
upgrade: yes
- name: Install mariadb as mysql server
pacman:
name: mariadb
state: present
register: mysqlinstall
- name: Install other requirements
pacman:
name: '{{ item }}'
state: present
with_items:
- redis
- mysql-python # Required for ansible
- name: Fix mysql
command: mysql_install_db --user=mysql --basedir=/usr/ --ldata=/var/lib/mysql/
when: mysqlinstall.changed
- name: Start and enable mysql and redis
service:
name: '{{ item }}'
state: started
enabled: yes
with_items:
- mysqld
- redis
- name: Configure redis to listen to external interfaces
lineinfile:
dest: /etc/redis.conf
regexp: ''
line: ''
state: present
with_items:
- { regexp: '^bind .*', line: 'bind 0.0.0.0 ::' }
- { regexp: '^supervised .*', line: 'supervised systemd' }
notify:
- restart redis
- name: Configure mysql to listen to external interface
lineinfile:
dest: /etc/mysql/my.cnf
regexp: '^bind-address .*'
line: '{{ item }}'
state: present
insertafter: '\[mysqld\]'
with_items:
- 'bind-address = 0.0.0.0'
- 'bind-address = ::'
notify:
- restart mysql
- name: Create mysql root user to listen from external hosts
mysql_user:
name: root
host: '%'
state: present
priv: '*.*:ALL,GRANT'
password: '{{ mysql_root_pw }}'
- name: Create database
mysql_db:
name: test
state: present
handlers:
- name: restart redis
service:
name: redis
state: restarted
- name: restart mysql
service:
name: mysqld
state: restarted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment