Skip to content
Snippets Groups Projects
Select Git revision
  • 0c5bcc242fcc8e9cfa0c2e1f2cb66690365309b5
  • master default protected
  • th/caddy-wip
  • th/caddy
  • th/lego
  • th/acmebot
  • pyzabbix
  • th/keycloak
8 results

main.yml

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    main.yml 2.90 KiB
    ---
    
    - name: install packages
      apt:
        name:
          - php
          - php-mbstring
          - php-mysql
          - php-intl
          - composer
    
    - name: install additional packages for the php sites
      apt:
        name: "{{item.packages}}"
      loop: "{{phpwebapps}}"
      when: item.packages is defined
      loop_control:
        label: "{{item.name}}"
    
    - name: ensure groups for the php sites exist
      group:
        name: "{{item.name}}"
        state: present
        system: true
      loop: "{{phpwebapps}}"
      loop_control:
        label: "{{item.name}}"
    
    - name: ensure groups for the php sites exist
      user:
        name: "{{item.name}}"
        group: "{{item.name}}"
        state: present
        system: true
        shell: /usr/bin/nologin
        home: "{{item.directory|default('/var/www/' + item.name)}}"
        createhome: false
      loop: "{{phpwebapps}}"
    
    - name: ensure directories for the php sites exist
      file:
        path: "{{item.directory|default('/var/www/' + item.name)}}"
        state: directory
        owner: "{{item.name}}"
        group: "{{item.name}}"
        mode: '0755'
      loop: "{{phpwebapps}}"
      loop_control:
        label: "{{item.name}}"
    
    - name: create the mysql database
      mysql_db:
        name: "{{item.name}}"
        state: present
        login_user: root
        login_password: "{{lookup('passwordstore', 'db/{{ansible_hostname}}-mysql')}}"
      no_log: true
      loop: "{{phpwebapps}}"
      loop_control:
        label: "{{item.name}}"
    
    - name: create mysql db user
      mysql_user:
        name: "{{item.name}}"
        password: "{{lookup('passwordstore', 'db/{{ansible_hostname}}-mysql-{{item.name}} create=true length=20')}}"
        state: present
        login_user: root
        login_password: "{{lookup('passwordstore', 'db/{{ansible_hostname}}-mysql')}}"
        priv: "{{item.name}}.*:ALL"
      no_log: true