elastic / ansible-elasticsearch

Ansible playbook for Elasticsearch
Other
1.59k stars 857 forks source link

filter_plugins/custom.py is skipped when ansible is installed through pip #819

Closed aymanrady closed 2 years ago

aymanrady commented 3 years ago

Elasticsearch version: 7.8.0

Role version: v7.14.0

JVM version: default

OS version: Ubuntu 20.04

Description of the problem including expected versus actual behaviour: Implicit dependency on six module breaks role when ansible is installed through pip instead of apt.

after further investigation, kitchen-ansible installs Ansible using apt on Ubuntu 20.04 which installs six through this dependency chain ansible 2.9.6 -> python3-cryptography 2.8 -> python3-six 1.14.0

installing Ansible through pip installs the latest version of cryptography (3.4.2 as of this writing), six was dropped from cryptography as of version 3.4 pyca/cryptography#5533

suggested solution: use the bundled ansible.module_utils.six instead of six

Playbook:

- name: Install Elasticsearch
  hosts: web
  become: yes
  roles:
    - { role: elasticsearch, tags: [elasticsearch], when: elastic_node | default(true) }

Provide logs from Ansible:

[WARNING]: Skipping plugin (/home/aymanrady/Development/projects/proper-
prawn/vendor/roles/elasticsearch/filter_plugins/custom.py) as it seems to be                                                                                                                                                                                                            
invalid: No module named 'six'

TASK [elasticsearch : Copy Configuration File] *********************************
System info:
  Ansible 2.10.13; Linux
---------------------------------------------------
AnsibleError: template error while templating string: No filter named
'array_to_str'.. String:
{% if es_config %}
{{ es_config | to_nice_yaml(indent=2) }}
{% endif %}

{% if es_config['cluster.name'] is not defined %}
cluster.name: elasticsearch
{% endif %}

{% if es_config['node.name'] is not defined %}
node.name: {{inventory_hostname}}
{% endif %}

#################################### Paths
####################################

# Path to directory containing configuration (this file and logging.yml):

path.data: {{ es_data_dirs | array_to_str }}

path.logs: {{ es_log_dir }}

{% if es_path_repo is defined %}
path.repo: {{ es_path_repo }}
{% endif %}

{% if es_action_auto_create_index == true %}
action.auto_create_index: true
{% elif not es_action_auto_create_index %}
action.auto_create_index: false
{% else %}
action.auto_create_index: {{ es_action_auto_create_index }}
{% endif %}

{% if not oss_version and es_api_basic_auth_username is defined and
es_api_basic_auth_password is defined %}
xpack.security.enabled: true

{% if es_enable_transport_ssl and es_enable_auto_ssl_configuration %}
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: "{{ es_ssl_verification_mode
}}"
{% if es_ssl_keystore and es_ssl_truststore %}
xpack.security.transport.ssl.keystore.path: "{{ es_ssl_certificate_path }}/{{
es_ssl_keystore | basename }}"
xpack.security.transport.ssl.truststore.path: "{{ es_ssl_certificate_path
}}/{{ es_ssl_truststore | basename }}"
{% elif es_ssl_key and  es_ssl_certificate %}
xpack.security.transport.ssl.key: "{{ es_ssl_certificate_path }}/{{
es_ssl_key | basename }}"
xpack.security.transport.ssl.certificate: "{{ es_ssl_certificate_path }}/{{
es_ssl_certificate | basename }}"
{% if es_ssl_certificate_authority %}
xpack.security.transport.ssl.certificate_authorities: "{{
es_ssl_certificate_path }}/{{ es_ssl_certificate_authority | basename }}"
{% endif %}
{% endif %}
{% endif %}

{% if es_enable_http_ssl and es_enable_auto_ssl_configuration %}
xpack.security.http.ssl.enabled: true
{% if es_ssl_keystore and es_ssl_truststore %}
xpack.security.http.ssl.keystore.path: "{{ es_ssl_certificate_path }}/{{
es_ssl_keystore | basename }}"
xpack.security.http.ssl.truststore.path: "{{ es_ssl_certificate_path }}/{{
es_ssl_truststore | basename }}"
{% elif es_ssl_key and  es_ssl_certificate %}
xpack.security.http.ssl.key: "{{ es_ssl_certificate_path }}/{{ es_ssl_key |
basename }}"
xpack.security.http.ssl.certificate: "{{ es_ssl_certificate_path }}/{{
es_ssl_certificate | basename }}"
{% if es_ssl_certificate_authority %}
xpack.security.http.ssl.certificate_authorities: "{{ es_ssl_certificate_path
}}/{{ es_ssl_certificate_authority | basename }}"
{% endif %}
{% endif %}
{% endif %}
{% endif %}

{% if es_mail_config is defined %}
xpack.notification.email:
  account:
    {{ es_mail_config['account'] }}:
      profile: {{ es_mail_config['profile'] }}
      email_defaults:
        from: {{ es_mail_config['from'] }}
      smtp:
        auth: {{ es_mail_config['require_auth'] }}
        host: {{ es_mail_config['host'] }}
        port: {{ es_mail_config['port'] }}
        {% if es_mail_config['require_auth'] == true -%}
        user: {{ es_mail_config['user'] }}
        password: {{ es_mail_config['pass'] }}
        {%- endif %}
{% endif %}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: {% endif %}
fatal: [*.*.*.*]: FAILED! => {"changed": false}
botelastic[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

botelastic[bot] commented 2 years ago

This issue has been automatically closed because it has not had recent activity since being marked as stale.