manala / manala-recipes

Manala recipes
https://manala.github.io/manala-recipes
8 stars 0 forks source link

[Elao - App] Issue with Redis server configuration #125

Closed Kocal closed 3 years ago

Kocal commented 3 years ago

Hey :)

Since https://github.com/manala/ansible-roles/issues/548 I'm trying your new skeleton (manala and manala-recipes) but I'm facing an issue when installing or configuring Redis.

I selected redis: * when running the recipe, and this is what happens when running VERBOSE=true DIFF=true make setup (full logs here):

TASK [manala.roles.redis : install > Packages] *********************************
task path: /home/vagrant/.ansible/collections/ansible_collections/manala/roles/roles/redis/tasks/install.yml:3
ok: [development] => {
    "cache_update_time": 1616832579, 
    "cache_updated": false, 
    "changed": false, 
    "invocation": {
        "module_args": {
            "allow_unauthenticated": false, 
            "autoclean": false, 
            "autoremove": false, 
            "cache_valid_time": 3600, 
            "deb": null, 
            "default_release": null, 
            "dpkg_options": "force-confdef,force-confold", 
            "force": false, 
            "force_apt_get": false, 
            "install_recommends": false, 
            "name": [
                "redis-server"
            ], 
            "only_upgrade": false, 
            "package": [
                "redis-server"
            ], 
            "policy_rc_d": null, 
            "purge": false, 
            "state": "present", 
            "update_cache": true, 
            "upgrade": null
        }
    }
}
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/commands/command.py
Pipelining is enabled.
<development> ESTABLISH LOCAL CONNECTION FOR USER: vagrant
<development> EXEC /bin/sh -c 'sudo -H -S -n  -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-rhvcjwuaqajrpnnkvkoszccxfvlfbsxj ; /usr/bin/python3'"'"' && sleep 0'

TASK [manala.roles.redis : install > Version] **********************************
task path: /home/vagrant/.ansible/collections/ansible_collections/manala/roles/roles/redis/tasks/install.yml:11
ok: [development] => {
    "changed": false, 
    "cmd": [
        "redis-server", 
        "--version"
    ], 
    "delta": "0:00:00.003139", 
    "end": "2021-03-27 08:19:40.213918", 
    "invocation": {
        "module_args": {
            "_raw_params": "redis-server --version", 
            "_uses_shell": false, 
            "argv": null, 
            "chdir": null, 
            "creates": null, 
            "executable": null, 
            "removes": null, 
            "stdin": null, 
            "stdin_add_newline": true, 
            "strip_empty_ends": true, 
            "warn": true
        }
    }, 
    "rc": 0, 
    "start": "2021-03-27 08:19:40.210779", 
    "stderr": "", 
    "stderr_lines": [], 
    "stdout": "Redis server v=5.0.3 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=1b271fe49834c463", 
    "stdout_lines": [
        "Redis server v=5.0.3 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=1b271fe49834c463"
    ]
}

TASK [manala.roles.redis : install > Version] **********************************
task path: /home/vagrant/.ansible/collections/ansible_collections/manala/roles/roles/redis/tasks/install.yml:15
ok: [development] => {
    "ansible_facts": {
        "manala_redis_version": "5.0"
    }, 
    "changed": false
}
<development> ESTABLISH LOCAL CONNECTION FOR USER: vagrant
<development> EXEC /bin/sh -c 'echo ~vagrant && sleep 0'
<development> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/vagrant/.ansible/tmp `"&& mkdir "` echo /home/vagrant/.ansible/tmp/ansible-tmp-1616833180.28-370-1236859768861 `" && echo ansible-tmp-1616833180.28-370-1236859768861="` echo /home/vagrant/.ansible/tmp/ansible-tmp-1616833180.28-370-1236859768861 `" ) && sleep 0'
<development> EXEC /bin/sh -c 'rm -f -r /home/vagrant/.ansible/tmp/ansible-tmp-1616833180.28-370-1236859768861/ > /dev/null 2>&1 && sleep 0'

TASK [manala.roles.redis : config > Server - Template] *************************
task path: /home/vagrant/.ansible/collections/ansible_collections/manala/roles/roles/redis/tasks/config.yml:3
fatal: [development]: FAILED! => {
    "changed": false, 
    "msg": "AnsibleError: Unexpected templating type error occurred on ({#- Deprecated -#}\n\n{%- set template_env = 'dev' -%}\n{%- include '_base.j2' -%}\n): 'NoneType' object is not iterable"
}

PLAY RECAP *********************************************************************
development                : ok=84   changed=1    unreachable=0    failed=1    skipped=73   rescued=0    ignored=0   

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
make: *** [.manala/Makefile:32 : setup] Erreur 1

My configuration files:

manala: recipe: elao.app

##########

System

##########

system: version: 10 hostname: localhost.symfony-app-template.fr nginx: configs:

Php fpm

      - file: app_php_fpm
        template: configs/app_php_fpm.dev.j2
      # Gzip
      - file: app_gzip
        template: configs/app_gzip.dev.j2
      # App
      - file: app.conf
        config:
          - server:
            - listen: 443 ssl
            - listen: 4430 ssl
            - listen: 4431 ssl
            - server_name: ~.
            - root: /srv/app/public
            - access_log: /srv/log/nginx.access.log
            - error_log: /srv/log/nginx.error.log
            - ssl_certificate: /srv/app/var/localhost.symfony-app-template.fr+1.pem
            - ssl_certificate_key: /srv/app/var/localhost.symfony-app-template.fr+1-key.pem
            - include: conf.d/app_gzip
            - location /:
              - try_files: $uri /index.php$is_args$args
            - location ~ ^/index\.php(/|$):
              - include: conf.d/app_php_fpm
              - set: $APP_ENV dev
              - if ( $server_port = 4430 ):
                - set: $APP_ENV test
              - if ( $server_port = 4431 ):
                - set: $APP_ENV prod
              - fastcgi_param: APP_ENV $APP_ENV
              - internal;
php:
    version: 7.4
    extensions:
      # Symfony
      - intl
      - curl
      - mbstring
      - xml
      # App
      - mysql
      - pgsql
    configs:
      - file: app_opcache.ini
        template: configs/app_opcache.dev.j2
      - file: app.ini
        template: configs/app.dev.j2
        config:
          - date.timezone: UTC
nodejs:
    version: 12
mariadb:
    version: 10.5
redis:
    version: '*'

files:
  # Single symfony app
  # ------------------
  - path: /srv/app/var/log
    src: /srv/log
    state: link_directory
    force: true
  - path: /srv/app/var/cache
    src: /srv/cache
    state: link_directory
    force: true
# ssh:
#     client:
#         config:
#           - Host *.elao.run:
#             - User: app
#             - ForwardAgent: true
- `.manala/ansible/inventories/system.yml`:
```yaml
system:
    hosts:

        ###############
        # Development #
        ###############

        development:
            # Ansible
            ansible_connection: local
            ansible_python_interpreter: /usr/bin/python3
            # Accounts
            manala_accounts_enabled: true
            # Motd
            manala_motd_enabled: true
            # Timezone
            manala_timezone_enabled: true
            # Locales
            manala_locales_enabled: true
            # Zsh
            manala_zsh_enabled: true
            # Environment
            manala_environment_enabled: true
            # Apt
            manala_apt_enabled: true
            manala_apt_packages:
              - xz-utils
              - rsync
              - wget
              - curl
              - make
              - less
              - ssl-cert
              - htop
              - pv # for real-time progress on streams (e.g mysql import)
            # Ssh
            manala_ssh_enabled: true
            manala_ssh_client_config_template: config/client/default.dev.j2
            # Git
            manala_git_enabled: true
            # Oh my zsh
            manala_ohmyzsh_enabled: true
            # Vim
            manala_vim_enabled: true
            # Alternatives
            manala_alternatives_enabled: true
            # Files
            manala_files_enabled: true
            # NodeJS
            manala_nodejs_enabled: true
            # Npm
            manala_npm_enabled: false
            # Php
            manala_php_enabled: true
            # Nginx
            manala_nginx_enabled: true
            # Supervisor
            manala_supervisor_enabled: false
            # Ngrok
            manala_ngrok_enabled: true
            # Java
            manala_java_enabled: false
            # Cron
            manala_cron_enabled: false
            # MySQL / MariaDB
            manala_mysql_enabled: true
            # Redis
            manala_redis_enabled: true
            # Elasticsearch
            manala_elasticsearch_enabled: false
            # InfluxDB
            manala_influxdb_enabled: false
            # Docker
            manala_docker_enabled: false # TODO: to fix
            # Gomplate
            manala_gomplate_enabled: true

        ###############
        # Integration #
        ###############

        integration:
            # Ansible
            ansible_connection: local
            ansible_python_interpreter: /usr/bin/python3
            # Apt
            manala_apt_enabled: true
            manala_apt_packages:
              - xz-utils
              - rsync
              - wget
              - curl
              - make
              - less
              - ssl-cert
              - procps
              - vim-tiny
            # Ssh
            manala_ssh_enabled: true
            manala_ssh_server: false
            manala_ssh_client_config_template: config/client/default.test.j2
            # Git
            manala_git_enabled: true
            # NodeJS
            manala_nodejs_enabled: true
            # Npm
            manala_npm_enabled: false
            # Php
            manala_php_enabled: true
            manala_php_sapis:
              - cli

    vars:

        #######
        # All #
        #######

        # Accounts
        manala_accounts_groups:
          - group: docker
            system: true
        manala_accounts_users:
          - user: vagrant
            group: vagrant
            groups: ['docker']

        # Motd
        manala_motd_scripts_exclusive: true
        manala_motd_scripts:
          - file: 10-motd
            template: motd/elao.j2
            message:
                - A curl vaillant, rien d'impossible !
                - --force et owner !
                - Il n'y pas de question cron, juste des réponses mal timé ! — Cronfucius

        # Timezone
        manala_timezone_default: Etc/UTC

        # Locales
        manala_locales_codes_default: C.UTF-8

        # Environment
        manala_environment_files:
          - zsh
        manala_environment_variables:
            COMPOSER_MEMORY_LIMIT: -1

        # Apt
        manala_apt:
          update: true
        manala_apt_configs:
          - file: archive
            template: configs/check_valid_until_false.j2
            state: "{{ (ansible_distribution_release in ['jessie']) | ternary('present', 'absent') }}"
        manala_apt_repositories_exclusive: true
        manala_apt_preferences_exclusive: true
        manala_apt_preferences:
          - ansible@ansible
          - preference: python-backports.ssl-match-hostname@manala
            state: "{{ (ansible_distribution_release in ['jessie']) | ternary('present', 'absent') }}"
          - preference: python-docker@manala
            state: "{{ (ansible_distribution_release in ['jessie']) | ternary('present', 'absent') }}"
          - preference: python-httplib2@manala
            state: "{{ (ansible_distribution_release in ['jessie']) | ternary('present', 'absent') }}"
          - preference: python-ipaddress@manala
            state: "{{ (ansible_distribution_release in ['jessie']) | ternary('present', 'absent') }}"
          - preference: python-jinja2@manala
            state: "{{ (ansible_distribution_release in ['jessie']) | ternary('present', 'absent') }}"
          - preference: python-websocket@manala
            state: "{{ (ansible_distribution_release in ['jessie']) | ternary('present', 'absent') }}"
          - preference: htop@backports
            state: "{{ (ansible_distribution_release in ['jessie']) | ternary('present', 'absent') }}"
          - preference: docker@docker
            state: "{{ (manala_docker_enabled) | ternary('present', 'absent') }}"
          - preference: git@backports
            state: "{{ (manala_git_enabled and (ansible_distribution_release in ['jessie', 'stretch'])) | ternary('present', 'absent') }}"
          - preference: supervisor@{{ (ansible_distribution_release in ['jessie']) | ternary('manala', 'backports') }}
            state: "{{ (manala_supervisor_enabled and (ansible_distribution_release in ['jessie', 'stretch'])) | ternary('present', 'absent') }}"
          - preference: php@sury_php
            state: "{{ (manala_php_enabled) | ternary('present', 'absent') }}"
          - preference: nginx@nginx
            state: "{{ (manala_nginx_enabled) | ternary('present', 'absent') }}"
          - preference: nodejs@nodesource_12
            state: "{{ (manala_nodejs_enabled) | ternary('present', 'absent') }}"
          - preference: yarn@yarn
            state: "{{ (manala_yarn_enabled) | ternary('present', 'absent') }}"
          - preference: mysql@default
            state: absent
          - preference: mariadb@mariadb_10_5
            state: present
          - preference: redis@{{ (ansible_distribution_release in ['stretch']) | ternary('backports', 'default') }}
            state: "{{ (manala_redis_enabled and (ansible_distribution_release in ['stretch'])) | ternary('present', 'absent') }}"
          - preference: elasticsearch@default
            state: "{{ (manala_elasticsearch_enabled) | ternary('present', 'absent') }}"
          - preference: influxdb@default
            state: "{{ (manala_influxdb_enabled) | ternary('present', 'absent') }}"

        # Ssh
        manala_ssh_server_config_template: config/server/default.dev.j2
        manala_ssh_server_config:
          - AcceptEnv: WORKDIR
        manala_ssh_known_hosts:
          - github.com
          - git.elao.com

        # Git
        manala_git_config_template: config/default.dev.j2

        # Oh my zsh
        manala_ohmyzsh_users:
          - user: vagrant
            group: vagrant
            template: users/php.dev.j2
            config:
              - "[ -d ${WORKDIR:-/srv/app} ] && cd ${WORKDIR:-/srv/app}"

        # Vim
        manala_vim_config_template: config/default.dev.j2

        # Alternatives
        manala_alternatives_selections:
          - selection: editor
            path: /usr/bin/vim.basic

        # Files
        manala_files_attributes_defaults:
          - parents: true
            force: true
          - path: "^/srv/log"
            user: vagrant
            group: vagrant
          - path: "^/srv/cache"
            user: vagrant
            group: vagrant
          - path: "^/srv/sessions"
            user: vagrant
            group: vagrant
        manala_files_attributes:
          - path: /srv/log
            state: directory
          - path: /srv/cache
            state: directory
          - path: /srv/sessions
            state: directory
          - path: /usr/share/nginx/html/404.html
            template: nginx/html/404.html.j2
            mode: "0644"
          # App
          - force: true
            path: /srv/app/var/log
            src: /srv/log
            state: link_directory
          - force: true
            path: /srv/app/var/cache
            src: /srv/cache
            state: link_directory

        # Yarn
        manala_yarn_enabled: "{{ manala_nodejs_enabled }}"

        # Php
        manala_php_version: 7.4
        manala_php_sapis_exclusive: true
        manala_php_fpm_pools_exclusive: true
        manala_php_fpm_pools:
          - file: app.conf
            template: fpm_pools/app.dev.j2
            config:
              - app:
                  - user: vagrant
                  - group: vagrant
                  - php_admin_value[error_log]: /srv/log/php.error.log
        manala_php_extensions_exclusive: true
        manala_php_extensions:
          - opcache
          - readline
          - extension: json
            state: "{{ 'present' if (manala_php_version and manala_php_version|string is version('8.0', '<')) else 'ignore' }}"
          - extension: xdebug
            enabled: false
          # App
          - intl
          - curl
          - mbstring
          - xml
          - mysql
          - pgsql
        manala_php_configs_exclusive: true
        manala_php_configs:
          - file: 50-xdebug.ini
            template: configs/xdebug.dev.j2
          # App
          - file: app_opcache.ini
            template: configs/app_opcache.dev.j2
          - config:
              - date.timezone: UTC
            file: app.ini
            template: configs/app.dev.j2

        # Composer
        manala_composer_enabled: "{{ manala_php_enabled }}"

        # Symfony Cli
        manala_symfony_cli_enabled: "{{ manala_php_enabled }}"

        # Nginx
        manala_nginx_config_template: config/http.dev.j2
        manala_nginx_configs_exclusive: true
        manala_nginx_configs:
          - file: default.conf
            config:
              - server:
                - listen: '* default_server'
                - error_page: '404 /404.html'
                - location /404.html:
                  - root: /usr/share/nginx/html
                  - internal;
          # App
          - file: app_php_fpm
            template: configs/app_php_fpm.dev.j2
          - file: app_gzip
            template: configs/app_gzip.dev.j2
          - config:
              - server:
                  - listen: 443 ssl
                  - listen: 4430 ssl
                  - listen: 4431 ssl
                  - server_name: ~.
                  - root: /srv/app/public
                  - access_log: /srv/log/nginx.access.log
                  - error_log: /srv/log/nginx.error.log
                  - ssl_certificate: /srv/app/var/localhost.symfony-app-template.fr+1.pem
                  - ssl_certificate_key: /srv/app/var/localhost.symfony-app-template.fr+1-key.pem
                  - include: conf.d/app_gzip
                  - location /:
                      - try_files: $uri /index.php$is_args$args
                  - location ~ ^/index\.php(/|$):
                      - include: conf.d/app_php_fpm
                      - set: $APP_ENV dev
                      - if ( $server_port = 4430 ):
                          - set: $APP_ENV test
                      - if ( $server_port = 4431 ):
                          - set: $APP_ENV prod
                      - fastcgi_param: APP_ENV $APP_ENV
                      - internal;
            file: app.conf

        # Supervisor
        manala_supervisor_config_template: config/debian/supervisord.conf.j2
        manala_supervisor_configs_exclusive: true
        manala_supervisor_configs_defaults:
          template: supervisor/app.conf.j2
        manala_supervisor_configs:
          - template: configs/inet_http_server.conf.j2
            config:
              port: "*:9001"

        # Ngrok
        manala_ngrok_configs_exclusive: true
        manala_ngrok_configs:
          - file: config.yml
            template: configs/default.dev.j2

        # Java
        manala_java_version: "{{
          {
            'jessie': '8',
            'stretch': '8',
            'buster': '11',
          }[ansible_distribution_release]
        }}"

        # Cron
        manala_cron_files_defaults:
          user: vagrant

        # MySQL / MariaDB
        manala_mysql_configs_dir: /etc/mysql/mariadb.conf.d
        manala_mysql_configs:
          - template: mysql/zz-mysqld.cnf.j2
        manala_mysql_users:
          # Create a password-less/any-host root user...
          - name: root
            password: ~
            host: "%"
            priv: "*.*:ALL,GRANT"
          # ...then remove anonymous localhost user (MySQL 5.6)
          - name: ''
            host: localhost
            state: absent
          # ...then remove root localhost user (socket based authentication on MySQL 5.7+/MariaDB)
          - name: root
            host: localhost
            state: absent
        manala_mysql_install_packages:
          - mariadb-server
          - mariadb-client

        # Redis
        manala_redis_config_template: config/default.dev.j2

        # Elasticsearch

        # Docker
        manala_docker_containers:
          - name: mailhog
            image: mailhog/mailhog:v1.0.1
            state: started
            restart_policy: unless-stopped
            ports:
              - 25:1025
              - 8025:8025
          - name: phpmyadmin
            image: phpmyadmin/phpmyadmin
            state: started
            restart_policy: unless-stopped
            env:
              PMA_USER: root
              # Default docker host ip
              PMA_HOST: 172.17.0.1
              UPLOAD_LIMIT: 64M
            ports:
              - 1979:80
          - name: phpredisadmin
            image: erikdubbelboer/phpredisadmin
            state: started
            restart_policy: unless-stopped
            env:
              # Default docker host ip
              REDIS_1_HOST: 172.17.0.1
            ports:
              - 1981:80

This is surely related to https://github.com/manala/ansible-roles/pull/515 but I don't really know what to do.

Do you know what happens? Thanks!

nervo commented 3 years ago

We're just in the middle of a massive pr (https://github.com/manala/manala-recipes/pull/123) which address, among others, this issue, and some other related to influxdb :) Could you retry when this will be closed ?

Kocal commented 3 years ago

Alright, I'm gonna wait then, thanks! :)

nervo commented 3 years ago

'should be solved by #123