|
377 | 377 | - perun_apache |
378 | 378 | - perun_config |
379 | 379 |
|
380 | | -- name: "list normal apache mounts" |
381 | | - set_fact: |
382 | | - apache_mounts: |
383 | | - - { type: volume, source: apache_logs, target: /var/log/apache2 } |
384 | | - - { type: bind, source: /etc/perun/ssl, target: /etc/perun/ssl, read_only: yes } |
385 | | - - { type: bind, source: /etc/perun/apache, target: /etc/perun/apache, read_only: yes } |
386 | | - # mount tmpfs to /tmp for faster performance https://docs.docker.com/storage/tmpfs/ |
387 | | - - { type: tmpfs, target: /tmp } |
388 | | - # bind syslog and journal from container to host, see https://www.projectatomic.io/blog/2016/10/playing-with-docker-logging/ |
389 | | - - { type: bind, source: /dev/log, target: /dev/log } |
390 | | - - { type: bind, source: /var/run/systemd/journal/socket, target: /var/run/systemd/journal/socket } |
391 | | - |
392 | | -- name: "add /etc/grid-security to apache mounts" |
393 | | - when: perun_apache_igtf_certs |
394 | | - set_fact: |
395 | | - apache_mounts: "{{ apache_mounts + [ { 'type': 'bind', 'source': '/etc/grid-security', 'target': '/etc/grid-security', 'read_only': 'yes' } ] }}" |
396 | | - |
397 | | -- name: "add perun_apache_mounts_additional to apache mounts" |
398 | | - when: perun_apache_mounts_additional|length > 0 |
399 | | - set_fact: |
400 | | - apache_mounts: "{{ apache_mounts + perun_apache_mounts_additional }}" |
401 | | - |
402 | | -- name: "add certbot dirs to apache mounts" |
403 | | - when: perun_use_certbot_certificates |
404 | | - set_fact: |
405 | | - apache_mounts: "{{ apache_mounts + perun_certbot_mounts }}" |
406 | | - |
407 | | -- name: "get perun_net info" |
408 | | - docker_network_info: |
409 | | - name: perun_net |
410 | | - register: perun_net_info |
411 | | - |
412 | | -- name: "create Perun Apache container" |
413 | | - docker_container: |
414 | | - name: perun_apache |
415 | | - hostname: perun-apache |
416 | | - image: "registry.gitlab.ics.muni.cz:443/perun/deployment/idm/perun_idm_docker/perun_apache:{{ perun_apache_container_version }}" |
417 | | - pull: yes |
418 | | - state: started |
419 | | - restart_policy: unless-stopped |
420 | | - mounts: "{{ apache_mounts }}" |
421 | | - networks_cli_compatible: yes |
422 | | - networks: |
423 | | - - name: perun_net |
424 | | - network_mode: perun_net |
425 | | - etc_hosts: "{{ perun_containers_etc_hosts | combine( { 'perun-host': perun_net_info.network.IPAM.Config[0].Gateway }) }}" |
426 | | - image_name_mismatch: recreate |
427 | | - comparisons: |
428 | | - '*': strict |
429 | | - ports: |
430 | | - - 80:80 |
431 | | - - 443:443 |
432 | | - default_host_ip: '' |
433 | | - register: perun_apache_container |
434 | | - |
435 | | -- name: "remove old hostname" |
436 | | - lineinfile: |
437 | | - dest: /etc/hosts |
438 | | - regexp: 'perun_apache' |
439 | | - state: absent |
440 | | - |
441 | | -- name: "put container IP into /etc/hosts" |
442 | | - lineinfile: |
443 | | - dest: /etc/hosts |
444 | | - regexp: "{{ perun_apache_container.container.Config.Hostname }}" |
445 | | - line: "{{ perun_apache_container.container.NetworkSettings.Networks.perun_net.IPAddress }} {{ perun_apache_container.container.Config.Hostname }}" |
| 380 | +- name: "container only" |
| 381 | + tags: |
| 382 | + - perun_apache_container |
| 383 | + block: |
| 384 | + - name: "list normal apache mounts" |
| 385 | + set_fact: |
| 386 | + apache_mounts: |
| 387 | + - { type: volume, source: apache_logs, target: /var/log/apache2 } |
| 388 | + - { type: bind, source: /etc/perun/ssl, target: /etc/perun/ssl, read_only: yes } |
| 389 | + - { type: bind, source: /etc/perun/apache, target: /etc/perun/apache, read_only: yes } |
| 390 | + # mount tmpfs to /tmp for faster performance https://docs.docker.com/storage/tmpfs/ |
| 391 | + - { type: tmpfs, target: /tmp } |
| 392 | + # bind syslog and journal from container to host, see https://www.projectatomic.io/blog/2016/10/playing-with-docker-logging/ |
| 393 | + - { type: bind, source: /dev/log, target: /dev/log } |
| 394 | + - { type: bind, source: /var/run/systemd/journal/socket, target: /var/run/systemd/journal/socket } |
| 395 | + |
| 396 | + - name: "add /etc/grid-security to apache mounts" |
| 397 | + when: perun_apache_igtf_certs |
| 398 | + set_fact: |
| 399 | + apache_mounts: "{{ apache_mounts + [ { 'type': 'bind', 'source': '/etc/grid-security', 'target': '/etc/grid-security', 'read_only': 'yes' } ] }}" |
| 400 | + |
| 401 | + - name: "add perun_apache_mounts_additional to apache mounts" |
| 402 | + when: perun_apache_mounts_additional|length > 0 |
| 403 | + set_fact: |
| 404 | + apache_mounts: "{{ apache_mounts + perun_apache_mounts_additional }}" |
| 405 | + |
| 406 | + - name: "add certbot dirs to apache mounts" |
| 407 | + when: perun_use_certbot_certificates |
| 408 | + set_fact: |
| 409 | + apache_mounts: "{{ apache_mounts + perun_certbot_mounts }}" |
| 410 | + |
| 411 | + - name: "get perun_net info" |
| 412 | + docker_network_info: |
| 413 | + name: perun_net |
| 414 | + register: perun_net_info |
| 415 | + |
| 416 | + - name: "create Perun Apache container" |
| 417 | + docker_container: |
| 418 | + name: perun_apache |
| 419 | + hostname: perun-apache |
| 420 | + image: "registry.gitlab.ics.muni.cz:443/perun/deployment/idm/perun_idm_docker/perun_apache:{{ perun_apache_container_version }}" |
| 421 | + pull: yes |
| 422 | + state: started |
| 423 | + restart_policy: unless-stopped |
| 424 | + mounts: "{{ apache_mounts }}" |
| 425 | + networks_cli_compatible: yes |
| 426 | + networks: |
| 427 | + - name: perun_net |
| 428 | + network_mode: perun_net |
| 429 | + etc_hosts: "{{ perun_containers_etc_hosts | combine( { 'perun-host': perun_net_info.network.IPAM.Config[0].Gateway }) }}" |
| 430 | + image_name_mismatch: recreate |
| 431 | + comparisons: |
| 432 | + '*': strict |
| 433 | + published_ports: |
| 434 | + - '0.0.0.0:80:80' |
| 435 | + - '443:443' |
| 436 | + default_host_ip: '' |
| 437 | + register: perun_apache_container |
| 438 | + |
| 439 | + - name: "put container IP into /etc/hosts" |
| 440 | + lineinfile: |
| 441 | + dest: /etc/hosts |
| 442 | + regexp: "{{ perun_apache_container.container.Config.Hostname }}" |
| 443 | + line: "{{ perun_apache_container.container.NetworkSettings.Networks.perun_net.IPAddress }} {{ perun_apache_container.container.Config.Hostname }}" |
0 commit comments