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:
parent
4a0404d917
commit
f38e6c1f6d
3
e107_tests/lib/ci/salt/.gitignore
vendored
Normal file
3
e107_tests/lib/ci/salt/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
cache/
|
||||
logs/
|
||||
var/
|
47
e107_tests/lib/ci/salt/README.md
Normal file
47
e107_tests/lib/ci/salt/README.md
Normal 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
|
||||
```
|
4
e107_tests/lib/ci/salt/Saltfile
Normal file
4
e107_tests/lib/ci/salt/Saltfile
Normal file
@ -0,0 +1,4 @@
|
||||
salt-ssh:
|
||||
roster_file: roster
|
||||
config_dir: .
|
||||
ssh_log_file: logs/salt-ssh
|
15
e107_tests/lib/ci/salt/master
Normal file
15
e107_tests/lib/ci/salt/master
Normal file
@ -0,0 +1,15 @@
|
||||
root_dir: ./
|
||||
|
||||
file_roots:
|
||||
base:
|
||||
- states/
|
||||
|
||||
pillar_roots:
|
||||
base:
|
||||
- pillars/
|
||||
|
||||
log_file: logs/master
|
||||
|
||||
cachedir: cache/
|
||||
|
||||
file_ignore_glob: []
|
1
e107_tests/lib/ci/salt/pillars/config-local.sls
Symbolic link
1
e107_tests/lib/ci/salt/pillars/config-local.sls
Symbolic link
@ -0,0 +1 @@
|
||||
../../../../config.local.yml
|
1
e107_tests/lib/ci/salt/pillars/config-sample.sls
Symbolic link
1
e107_tests/lib/ci/salt/pillars/config-sample.sls
Symbolic link
@ -0,0 +1 @@
|
||||
../../../../config.sample.yml
|
1
e107_tests/lib/ci/salt/pillars/config.sls
Symbolic link
1
e107_tests/lib/ci/salt/pillars/config.sls
Symbolic link
@ -0,0 +1 @@
|
||||
../../../../config.yml
|
5
e107_tests/lib/ci/salt/pillars/top.sls
Normal file
5
e107_tests/lib/ci/salt/pillars/top.sls
Normal file
@ -0,0 +1,5 @@
|
||||
base:
|
||||
e107-dev:
|
||||
- config-sample
|
||||
- config
|
||||
- config-local
|
1
e107_tests/lib/ci/salt/roster
Normal file
1
e107_tests/lib/ci/salt/roster
Normal file
@ -0,0 +1 @@
|
||||
e107-dev: 10.64.229.116
|
40
e107_tests/lib/ci/salt/states/e107-dev.sls
Normal file
40
e107_tests/lib/ci/salt/states/e107-dev.sls
Normal 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: '%'
|
@ -0,0 +1,2 @@
|
||||
[mysqld]
|
||||
bind-address = 0.0.0.0
|
Loading…
x
Reference in New Issue
Block a user