Browse Source

Exercise 3: Add assignment e

master
Pekka Helenius 6 years ago
committed by GitHub
parent
commit
e6706104da
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 109 additions and 0 deletions
  1. +109
    -0
      h3.md

+ 109
- 0
h3.md View File

@ -528,3 +528,112 @@ mutta tässä varmistamme SSH-yhteyden toimivuuden portissa 240 suoraan minionin
/etc/ssh/sshd_config -tiedoston sisältöä SSH-client testauksineen orjakoneen näkymästä ylläolevan ajon jälkeen:
![randomport-from-master](https://raw.githubusercontent.com/Fincer-altego/central-management-of-multiple-servers/master/images/ssh_randomport_for_minion.png)
**e)** Kokeile jonkun toisen opiskelijan tekemää Salt-tilaa. Kokeiltava tila voi olla mistä vain harjoituksesta. Opiskelijoiden raportteja ja koodeja löydät tämän sivun perästä kommenteista.
--------------
**Vastaus:**
Valitaan henkilön Oliver Siren harjoitus 3:n [Salt state, Jinja for-in loop](https://github.com/Oliver-Siren/palvelinten-hallinta-ict4tn022-4/blob/master/assignments/h3.md#salt-state-jinja-for-in-loop) -tehtävän vastaus.
Ladataan wget-komennolla init.sls-tiedosto masterilla paikalliseen kansioon _/srv/salt/student_sample_:
SLS-tiedostossa on oletettu, että tiedosto _/srv/salt/jinja/fool.txt_ on olemassa masterilla. Koska sitä ei ole, me luomme sen alla olevassa komentorimpsussa.
```
sudo -- sh -c ' \
mkdir -p /srv/salt/student_sample && mkdir -p /srv/salt/jinja && \
wget https://raw.githubusercontent.com/Oliver-Siren/palvelinten-hallinta-ict4tn022-4/master/assignments/h3.md -O /srv/salt/student_sample/init.sls && \
sed -i '51,61!d' /srv/salt/student_sample/init.sls && \
echo "This is your {{ file }}" > /srv/salt/jinja/fool.txt
'
```
Ajetaan tila masterilta kaikille saataville orja-alkuisille minioneille:
```
sudo salt 'orja*' state.apply student_sample
```
Masterilla saatu output:
```
orjakone:
----------
ID: /tmp/fool/first.txt
Function: file.managed
Result: True
Comment: File /tmp/fool/first.txt updated
Started: 00:16:20.842493
Duration: 25.759 ms
Changes:
----------
diff:
New file
mode:
0644
----------
ID: /tmp/fool/second.txt
Function: file.managed
Result: True
Comment: File /tmp/fool/second.txt updated
Started: 00:16:20.868344
Duration: 19.281 ms
Changes:
----------
diff:
New file
mode:
0644
----------
ID: /tmp/fool/third.txt
Function: file.managed
Result: True
Comment: File /tmp/fool/third.txt updated
Started: 00:16:20.887697
Duration: 17.221 ms
Changes:
----------
diff:
New file
mode:
0644
----------
ID: /tmp/fool/fourth.txt
Function: file.managed
Result: True
Comment: File /tmp/fool/fourth.txt updated
Started: 00:16:20.904989
Duration: 19.971 ms
Changes:
----------
diff:
New file
mode:
0644
Summary for orjakone
------------
Succeeded: 4 (changed=4)
Failed: 0
------------
Total states run: 4
Total run time: 82.232 ms
```
Wget:llä ladatun ja sed:llä parsitun esimerkki-SLS -tiedoston sisältö:
```
{% for tiedosto in ['first.txt', 'second.txt', 'third.txt', 'fourth.txt'] %}
/tmp/fool/{{ tiedosto }}:
file.managed:
- source: salt://jinja/fool.txt
- makedirs: True
- template: jinja
- context:
file: {{ tiedosto }}
{% endfor %}
```

Loading…
Cancel
Save