1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-20 04:32:01 +02:00

Added a salt-ssh state to deploy an LXC dev env

This commit is contained in:
Nick Liu 2019-12-23 15:19:26 +01:00
parent 4a0404d917
commit f38e6c1f6d
No known key found for this signature in database
GPG Key ID: 1167C5F9C9897637
11 changed files with 120 additions and 0 deletions

3
e107_tests/lib/ci/salt/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
cache/
logs/
var/

View File

@ -0,0 +1,47 @@
# Development Environment Deployment
1. Launch a development container:
```
lxc launch -s local images:ubuntu/focal e107-dev
```
2. Push your public SSH key:
```
lxc file push --uid 0 --gid 0 -pv ~/.ssh/id_rsa.pub e107-dev/root/.ssh/authorized_keys
```
3. Install OpenSSH Server:
```
lxc exec e107-dev -- apt install -y openssh-server
```
4. Note the IP of the container:
```
E107_DEV_HOST=$(lxc exec e107-dev -- hostname -I | cut -d' ' -f1)
```
5. Generate the [Salt SSH](https://docs.saltstack.com/en/latest/topics/ssh/) [roster](https://docs.saltstack.com/en/latest/topics/ssh/roster.html):
```
echo "e107-dev: $E107_DEV_HOST" | tee roster
```
6. Configure `e107_tests/config.yml` based on `e107_tests/config.sample.yml` (from the root of this repository).
Set `db.dbname`, `db.user`, and `db.password` to what you want the container configuration to have.
Set `db.host` to the value of `$E107_DEV_HOST`.
7. Apply the container configuration:
```
salt-ssh 'e107-dev' --state-output=changes state.apply e107-dev
```

View File

@ -0,0 +1,4 @@
salt-ssh:
roster_file: roster
config_dir: .
ssh_log_file: logs/salt-ssh

View File

@ -0,0 +1,15 @@
root_dir: ./
file_roots:
base:
- states/
pillar_roots:
base:
- pillars/
log_file: logs/master
cachedir: cache/
file_ignore_glob: []

View File

@ -0,0 +1 @@
../../../../config.local.yml

View File

@ -0,0 +1 @@
../../../../config.sample.yml

View File

@ -0,0 +1 @@
../../../../config.yml

View File

@ -0,0 +1,5 @@
base:
e107-dev:
- config-sample
- config
- config-local

View File

@ -0,0 +1 @@
e107-dev: 10.64.229.116

View File

@ -0,0 +1,40 @@
Install MySQL server:
pkg.installed:
- pkgs:
- mariadb-server
- python3-mysqldb
MySQL server configuration file:
file.managed:
- name: /etc/mysql/mariadb.conf.d/99-overrides.cnf
- source: salt://files/etc/mysql/mariadb.conf.d/99-overrides.cnf
- user: root
- group: root
- mode: 0644
- template: jinja
Start and enable MySQL server daemon:
service.running:
- name: mysql
- enable: True
- watch:
- file: /etc/mysql/mariadb.conf.d/99-overrides.cnf
Create MySQL user:
mysql_user.present:
- name: {{ salt['pillar.get']('db:user') }}
- host: '%'
- password: {{ salt['pillar.get']('db:password') }}
- allow_passwordless: True
- unix_socket: False
Create MySQL database:
mysql_database.present:
- name: {{ salt['pillar.get']('db:dbname') }}
Create MySQL grants:
mysql_grants.present:
- grant: ALL PRIVILEGES
- database: {{ salt['pillar.get']('db:dbname') }}.*
- user: {{ salt['pillar.get']('db:user') }}
- host: '%'

View File

@ -0,0 +1,2 @@
[mysqld]
bind-address = 0.0.0.0