Asenna Lamp-saltilla
Ensimmäisenä juoksutin orjalla scriptin, joka asentaa salt minionin ja konfiguroi koneen.
sudo apt-get -y install salt-minion |
echo -e 'master: 192.168.0.150\nid: Orja'|sudo tee /etc/salt/minion |
sudo systemctl restart salt-minion |
sudo apt-get install -y git |
sudo git config --global user.email "a1704537@myy.haaga-helia.fi" |
sudo git config --global user.name "Sam" |
sudo git clone https://github.com/samuli-salonen/tesmi.git |
sudo systemctl restart git |
echo "done"
Sitten aloin tekemään /srv/salt/ kansioon tiedostoa nimeltä lamp.sls, johon laitoin:
|
apache2: |
/var/www/html/index.html: |
- source: salt://index.html |
/etc/apache2/mods-enabled/userdir.conf: |
- target: ../mods-available/userdir.conf |
/etc/apache2/mods-enabled/userdir.load: |
- target: ../mods-available/userdir.load |
- file: /etc/apache2/mods-enabled/userdir.conf |
- file: /etc/apache2/mods-enabled/userdir.load |
- source: salt://lampsh.sh |
- /etc/salt/tehty.log |
Tämän jälkeen tein shell scriptin, joka tekee databasen ja antaa sille oikeudet mariadb:ssä
echo "CREATE DATABASE testi10;" | sudo mariadb -u root |
echo "GRANT ALL ON testi.* TO lamporja@localhost IDENTIFIED BY '1234';"$ |
echo "Test database on tehty" | sudo tee /etc/salt/tehty.log |
Mainitsin lamp.sls top.sls:ssä, Josta sain tulokseksi ajamalla komennon sudo salt '*' state.highstate.
(Ps. olin jo ajanut koodin testauksen aikana)
Comment: All specified packages are already installed |
Comment: All specified packages are already installed |
Comment: All specified packages are already installed |
ID: /var/www/html/index.html |
Comment: File /var/www/html/index.html is in the correct state |
ID: /etc/apache2/mods-enabled/userdir.conf |
Comment: Symlink /etc/apache2/mods-enabled/userdir.conf is present and owned by root:root |
ID: /etc/apache2/mods-enabled/userdir.load |
Comment: Symlink /etc/apache2/mods-enabled/userdir.load is present and owned by root:root |
Function: service.running |
Comment: The service apache2 is already running |
Comment: All files in creates exist |
Total run time: 685.589 ms
Sitten katsotaan tuliko database Orjalle:
Ja tulihan se!
lähde:
https://github.com/a1704565/salt/blob/master/raportti-h6.md
lähde:
http://terokarvinen.com/2018/pkg-file-service-control-daemons-with-salt-change-ssh-server-port
Ei kommentteja:
Lähetä kommentti