additional course material RH294
Student User
2020-02-19 8b862483000e30613e2079356141ed730015d306
course Bern 2020-02-19
2 files deleted
7 files added
5 files modified
112 ■■■■ changed files
complex-magic.yaml 8 ●●●●● patch | view | raw | blame | history
facts-scan.yaml 8 ●●●●● patch | view | raw | blame | history
geheim.yaml 12 ●●●●● patch | view | raw | blame | history
group_vars/server 1 ●●●● patch | view | raw | blame | history
hash-or-dict-loop.yml 8 ●●●● patch | view | raw | blame | history
host_vars/serverd 3 ●●●●● patch | view | raw | blame | history
inventory 7 ●●●● patch | view | raw | blame | history
play-with-var.yml 6 ●●●● patch | view | raw | blame | history
simple-blockinfile.yaml 19 ●●●●● patch | view | raw | blame | history
simple-loop.yml 2 ●●● patch | view | raw | blame | history
simple-magic.yaml 9 ●●●●● patch | view | raw | blame | history
simple-ping.yaml 7 ●●●●● patch | view | raw | blame | history
stub-var.yaml 8 ●●●●● patch | view | raw | blame | history
userarray.yaml 14 ●●●●● patch | view | raw | blame | history
complex-magic.yaml
New file
@@ -0,0 +1,8 @@
---
- name: complex demo of magic var
  hosts: server
  become: true
  tasks:
    - name: "dump hostvars"
      debug:
        msg: '{{ hostvars["servera"]["ansible_facts"]["fqdn"] }}'
facts-scan.yaml
New file
@@ -0,0 +1,8 @@
---
- name: scan facts
  hosts: demoext
  become: false
  tasks:
    - debug:
        msg: 'FS {{ item["device"] }} mounted on {{ item["mount"] }} has size of {{ item["size_total"] }}'
      loop: '{{ ansible_facts["mounts"] }}'
geheim.yaml
@@ -1,6 +1,8 @@
$ANSIBLE_VAULT;1.1;AES256
39346335653063616631343434623038353466366661386439353535656661663438316565306532
3632373833326562613263313863626336333131623463340a316465653331636639336261356136
39366432316232366263336561653735323835323839636263393835333235356130623236346362
3833656164366563610a323334353637653766613834306162643736336438663266376438636566
38323636323264376637323464616433633939613230663039396362626362353265
34376535376362333333336334373939353137616634316535303431313262323466356136643131
3335383635643937383265643035386130386465646439360a363161623236343236393366663231
62376238646638323033373066653739616331386466663865363434313935366561396438636433
3366643061663538300a653138626563303235653865353666336637326363363330376566323462
35383136353733363231653864313131346132623938656231313961623565626463663535333635
31363731663433383131653838383632366561646664636436613262383566616438656532353361
653461363330316264386532623236353639
group_vars/server
File was deleted
hash-or-dict-loop.yml
@@ -20,11 +20,15 @@
        shell: "{{ item['shell'] }}"
        state: "{{ installstate }}"
      loop: "{{ users }}"
      register: userregister
      when: run_my_task
    - name: 'show created users'
      shell: getent passwd
      register: geout
    - debug:
        msg: "{{ geout.stdout }}"
        msg: "{{ geout.stdout_lines }}"
    - debug:
        var: userregister
        
host_vars/serverd
File was deleted
inventory
@@ -19,8 +19,11 @@
serverd svcname=mariadb
[ext]
x230 remote_user=do407
#x230 remote_user=do407
demoext ansible_host=172.25.254.44 remote_user=devops ansible_python_interpreter=auto_silent
[desktop]
workstation
workstation
play-with-var.yml
@@ -1,5 +1,5 @@
---
- name: Simple play that sets up webservers
- name: 'Simple play that sets up webservers'
  hosts: server
  become: true
  vars_files:
@@ -14,6 +14,10 @@
        name: '{{ svcname }}'
        state: started
        enabled: true
    - name: 'store secret data in secretfile'
      copy:
        dest: /very-secret-file.txt
        content: '{{ secretstuff }}'
      
- name: 'Next play to verify for the webserver process'
  hosts: server
simple-blockinfile.yaml
New file
@@ -0,0 +1,19 @@
---
- name: demo blockinfile
  hosts: server
  become: true
  vars:
    installstate: present
  tasks:
    - name: "copy some lines into /etc/profile"
      blockinfile:
        path: /etc/profile
        block: |
          #This is a
          #phantastic
          #block using
          #ansible
          #blockinfile
        marker: "# {mark} OLAFS SUPER BLOCK"
        state: '{{ installstate }}'
        insertbefore: "^unset i$"
simple-loop.yml
@@ -20,6 +20,6 @@
      shell: ls -l /home/student
      register: lsout
    - debug:
        msg: "{{ lsout.stdout }}"
        msg: "{{ lsout.stdout_lines }}"
        
        
simple-magic.yaml
New file
@@ -0,0 +1,9 @@
---
- name: demo of magic var
  hosts: servera
  become: true
  tasks:
    - name: "write inventory data to file"
      copy:
        dest: /inventory-file
        content: '{{ groups | to_pretty_json }}'
simple-ping.yaml
New file
@@ -0,0 +1,7 @@
---
- name: ping hosts
  hosts: all
  tasks:
    - name: is all alive
      ping:
        data: blah
stub-var.yaml
New file
@@ -0,0 +1,8 @@
---
- name: stub print vars
  hosts: localhost
  become: false
  tasks:
    - name: print a var
      debug:
        msg: '{{ myvar }}'
userarray.yaml
New file
@@ -0,0 +1,14 @@
users:
  bjones:
    first_name: Bob
    last_name: Jones
    home_dir: /users/bjones
  acook:
    first_name: Anne
    last_name: Cook
    home_dir: /users/acook
  {{ users.bjones.first_name }}
  {{ users['bjones']['first_name'] }}