Skip to content

Instantly share code, notes, and snippets.

@ostcar
Created October 13, 2015 14:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ostcar/208f12b68c129297c10f to your computer and use it in GitHub Desktop.
Save ostcar/208f12b68c129297c10f to your computer and use it in GitHub Desktop.
systemd-nspawn config for inyoka providing mysql and redis
---
- hosts: inyoka_dev
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
- name: Upgrade system # Can be merged with the task above in ansible 2.0
command: /usr/bin/pacman -Sy
- 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: '^bind .*'
line: 'bind 0.0.0.0'
state: present
notify:
- restart redis
- name: Configure mysql to listen to external interface
lineinfile:
dest: /etc/mysql/my.cnf
regexp: '^bind-address .*'
line: 'bind-address = 0.0.0.0'
state: present
insertafter: '\[mysqld\]'
notify:
- restart mysql
- name: Create mysql root user to listen from external hosts
mysql_user:
name: root
host: '%'
state: present
priv: '*.*:ALL,GRANT'
password: ''
- name: Create database for inyoka
mysql_db:
name: ubuntuusers
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