mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
(cherry picked from commit 20db4fc560
)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
d85d31ba3c
commit
8a8e6c8058
19 changed files with 45 additions and 45 deletions
|
@ -46,16 +46,16 @@ options:
|
||||||
msg:
|
msg:
|
||||||
type: str
|
type: str
|
||||||
description:
|
description:
|
||||||
- The contents of the annotation message, in plain text. Limited to 256 characters. Required for annotation.
|
- The contents of the annotation message, in plain text. Limited to 256 characters. Required for annotation.
|
||||||
annotated_by:
|
annotated_by:
|
||||||
type: str
|
type: str
|
||||||
description:
|
description:
|
||||||
- The person or robot who the annotation should be attributed to.
|
- The person or robot who the annotation should be attributed to.
|
||||||
default: "Ansible"
|
default: "Ansible"
|
||||||
level:
|
level:
|
||||||
type: str
|
type: str
|
||||||
description:
|
description:
|
||||||
- one of INFO/WARN/ERROR, defaults to INFO if not supplied. May affect display.
|
- one of INFO/WARN/ERROR, defaults to INFO if not supplied. May affect display.
|
||||||
choices: ['INFO', 'WARN', 'ERROR']
|
choices: ['INFO', 'WARN', 'ERROR']
|
||||||
default: 'INFO'
|
default: 'INFO'
|
||||||
instance_id:
|
instance_id:
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
##############
|
##############
|
||||||
# Test parameters:
|
# Test parameters:
|
||||||
# link parameter present / absent ('with_link' variable)
|
# link parameter present / absent ('with_link' variable)
|
||||||
# with / without alternatives defined in alternatives file ('with_alternatives' variable)
|
# with / without alternatives defined in alternatives file ('with_alternatives' variable)
|
||||||
# auto / manual ('mode' variable)
|
# auto / manual ('mode' variable)
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@
|
||||||
path: '{{ item }}'
|
path: '{{ item }}'
|
||||||
state: absent
|
state: absent
|
||||||
with_items:
|
with_items:
|
||||||
- '{{ alternatives_dir }}/dummy'
|
- '{{ alternatives_dir }}/dummy'
|
||||||
|
|
||||||
- file:
|
- file:
|
||||||
path: '/usr/bin/dummy{{ item }}'
|
path: '/usr/bin/dummy{{ item }}'
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
- template:
|
- template:
|
||||||
src: dummy_alternative
|
src: dummy_alternative
|
||||||
dest: '{{ alternatives_dir }}/dummy'
|
dest: '{{ alternatives_dir }}/dummy'
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: '0644'
|
mode: '0644'
|
||||||
when: with_alternatives or ansible_os_family != 'RedHat'
|
when: with_alternatives or ansible_os_family != 'RedHat'
|
||||||
- file:
|
- file:
|
||||||
path: '{{ alternatives_dir }}/dummy'
|
path: '{{ alternatives_dir }}/dummy'
|
||||||
state: absent
|
state: absent
|
||||||
when: not with_alternatives and ansible_os_family == 'RedHat'
|
when: not with_alternatives and ansible_os_family == 'RedHat'
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
- name: set alternative (using link parameter)
|
- name: set alternative (using link parameter)
|
||||||
alternatives:
|
alternatives:
|
||||||
name: dummy
|
name: dummy
|
||||||
path: '/usr/bin/dummy{{ item }}'
|
path: '/usr/bin/dummy{{ item }}'
|
||||||
link: '/usr/bin/dummy'
|
link: '/usr/bin/dummy'
|
||||||
register: alternative
|
register: alternative
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
- name: set alternative (without link parameter)
|
- name: set alternative (without link parameter)
|
||||||
alternatives:
|
alternatives:
|
||||||
name: dummy
|
name: dummy
|
||||||
path: '/usr/bin/dummy{{ item }}'
|
path: '/usr/bin/dummy{{ item }}'
|
||||||
register: alternative
|
register: alternative
|
||||||
|
|
||||||
- name: check expected command was executed
|
- name: check expected command was executed
|
||||||
|
@ -40,11 +40,11 @@
|
||||||
- 'cmd.stdout == "dummy" ~ item'
|
- 'cmd.stdout == "dummy" ~ item'
|
||||||
|
|
||||||
- name: 'check mode (manual: alternatives file existed, it has been updated)'
|
- name: 'check mode (manual: alternatives file existed, it has been updated)'
|
||||||
shell: 'head -n1 {{ alternatives_dir }}/dummy | grep "^manual$"'
|
shell: 'head -n1 {{ alternatives_dir }}/dummy | grep "^manual$"'
|
||||||
when: ansible_os_family != 'RedHat' or with_alternatives or item != 1
|
when: ansible_os_family != 'RedHat' or with_alternatives or item != 1
|
||||||
|
|
||||||
- name: 'check mode (auto: alternatives file didn''t exist, it has been created)'
|
- name: 'check mode (auto: alternatives file didn''t exist, it has been created)'
|
||||||
shell: 'head -n1 {{ alternatives_dir }}/dummy | grep "^auto$"'
|
shell: 'head -n1 {{ alternatives_dir }}/dummy | grep "^auto$"'
|
||||||
when: ansible_os_family == 'RedHat' and not with_alternatives and item == 1
|
when: ansible_os_family == 'RedHat' and not with_alternatives and item == 1
|
||||||
|
|
||||||
- name: check that alternative has been updated
|
- name: check that alternative has been updated
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
name: dummy
|
name: dummy
|
||||||
path: '/usr/bin/dummy{{ item }}'
|
path: '/usr/bin/dummy{{ item }}'
|
||||||
link: /usr/bin/dummy
|
link: /usr/bin/dummy
|
||||||
priority: '{{ 60 + item|int }}'
|
priority: '{{ 60 + item|int }}'
|
||||||
register: alternative
|
register: alternative
|
||||||
|
|
||||||
- name: execute dummy command
|
- name: execute dummy command
|
||||||
|
@ -11,13 +11,13 @@
|
||||||
register: cmd
|
register: cmd
|
||||||
|
|
||||||
- name: check if link group is in manual mode
|
- name: check if link group is in manual mode
|
||||||
shell: 'head -n1 {{ alternatives_dir }}/dummy | grep "^manual$"'
|
shell: 'head -n1 {{ alternatives_dir }}/dummy | grep "^manual$"'
|
||||||
|
|
||||||
- name: check expected command was executed
|
- name: check expected command was executed
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- 'alternative is changed'
|
- 'alternative is changed'
|
||||||
- 'cmd.stdout == "dummy{{ item }}"'
|
- 'cmd.stdout == "dummy{{ item }}"'
|
||||||
|
|
||||||
- name: check that alternative has been updated
|
- name: check that alternative has been updated
|
||||||
command: "grep -Pzq '/bin/dummy{{ item }}\\n{{ 60 + item|int }}' '{{ alternatives_dir }}/dummy'"
|
command: "grep -Pzq '/bin/dummy{{ item }}\\n{{ 60 + item|int }}' '{{ alternatives_dir }}/dummy'"
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
####################################################################
|
####################################################################
|
||||||
|
|
||||||
- ansible.builtin.debug:
|
- ansible.builtin.debug:
|
||||||
msg: '{{ role_name }}'
|
msg: '{{ role_name }}'
|
||||||
- ansible.builtin.debug:
|
- ansible.builtin.debug:
|
||||||
msg: '{{ role_path|basename }}'
|
msg: '{{ role_path|basename }}'
|
||||||
- import_tasks: setup.yml
|
- import_tasks: setup.yml
|
||||||
|
|
||||||
- include_vars: "{{ lookup('first_found', search) }}"
|
- include_vars: "{{ lookup('first_found', search) }}"
|
||||||
|
|
|
@ -100,7 +100,7 @@
|
||||||
|
|
||||||
- name: "Install dosfstools and lvm2 (Linux)"
|
- name: "Install dosfstools and lvm2 (Linux)"
|
||||||
ansible.builtin.package:
|
ansible.builtin.package:
|
||||||
name: '{{ item }}'
|
name: '{{ item }}'
|
||||||
with_items:
|
with_items:
|
||||||
- dosfstools
|
- dosfstools
|
||||||
- lvm2
|
- lvm2
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
- vars:
|
- vars:
|
||||||
# sample: node-v8.2.0-linux-x64.tar.xz
|
# sample: node-v8.2.0-linux-x64.tar.xz
|
||||||
node_path: '{{ remote_dir }}/{{ nodejs_path }}/bin'
|
node_path: '{{ remote_dir }}/{{ nodejs_path }}/bin'
|
||||||
package: 'ncp'
|
package: 'ncp'
|
||||||
block:
|
block:
|
||||||
- shell: npm --version
|
- shell: npm --version
|
||||||
|
@ -20,12 +20,12 @@
|
||||||
- name: 'Install simple package with no_bin_links disabled'
|
- name: 'Install simple package with no_bin_links disabled'
|
||||||
npm:
|
npm:
|
||||||
path: '{{ remote_dir }}'
|
path: '{{ remote_dir }}'
|
||||||
executable: '{{ node_path }}/npm'
|
executable: '{{ node_path }}/npm'
|
||||||
state: present
|
state: present
|
||||||
name: '{{ package }}'
|
name: '{{ package }}'
|
||||||
no_bin_links: false
|
no_bin_links: false
|
||||||
environment:
|
environment:
|
||||||
PATH: '{{ node_path }}:{{ ansible_env.PATH }}'
|
PATH: '{{ node_path }}:{{ ansible_env.PATH }}'
|
||||||
register: npm_install_no_bin_links_disabled
|
register: npm_install_no_bin_links_disabled
|
||||||
|
|
||||||
- name: 'Make sure .bin folder has been created'
|
- name: 'Make sure .bin folder has been created'
|
||||||
|
@ -41,12 +41,12 @@
|
||||||
- name: 'Install simple package with no_bin_links enabled'
|
- name: 'Install simple package with no_bin_links enabled'
|
||||||
npm:
|
npm:
|
||||||
path: '{{ remote_dir }}'
|
path: '{{ remote_dir }}'
|
||||||
executable: '{{ node_path }}/npm'
|
executable: '{{ node_path }}/npm'
|
||||||
state: present
|
state: present
|
||||||
name: '{{ package }}'
|
name: '{{ package }}'
|
||||||
no_bin_links: true
|
no_bin_links: true
|
||||||
environment:
|
environment:
|
||||||
PATH: '{{ node_path }}:{{ ansible_env.PATH }}'
|
PATH: '{{ node_path }}:{{ ansible_env.PATH }}'
|
||||||
register: npm_install_no_bin_links_enabled
|
register: npm_install_no_bin_links_enabled
|
||||||
|
|
||||||
- name: 'Make sure .bin folder has not been created'
|
- name: 'Make sure .bin folder has not been created'
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
- vars:
|
- vars:
|
||||||
# sample: node-v8.2.0-linux-x64.tar.xz
|
# sample: node-v8.2.0-linux-x64.tar.xz
|
||||||
node_path: '{{ remote_dir }}/{{ nodejs_path }}/bin'
|
node_path: '{{ remote_dir }}/{{ nodejs_path }}/bin'
|
||||||
package: 'iconv-lite'
|
package: 'iconv-lite'
|
||||||
block:
|
block:
|
||||||
- shell: npm --version
|
- shell: npm --version
|
||||||
|
@ -19,11 +19,11 @@
|
||||||
- name: 'Install simple package without dependency'
|
- name: 'Install simple package without dependency'
|
||||||
npm:
|
npm:
|
||||||
path: '{{ remote_dir }}'
|
path: '{{ remote_dir }}'
|
||||||
executable: '{{ node_path }}/npm'
|
executable: '{{ node_path }}/npm'
|
||||||
state: present
|
state: present
|
||||||
name: '{{ package }}'
|
name: '{{ package }}'
|
||||||
environment:
|
environment:
|
||||||
PATH: '{{ node_path }}:{{ ansible_env.PATH }}'
|
PATH: '{{ node_path }}:{{ ansible_env.PATH }}'
|
||||||
register: npm_install
|
register: npm_install
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
state: present
|
state: present
|
||||||
name: '{{ package }}'
|
name: '{{ package }}'
|
||||||
environment:
|
environment:
|
||||||
PATH: '{{ node_path }}:{{ ansible_env.PATH }}'
|
PATH: '{{ node_path }}:{{ ansible_env.PATH }}'
|
||||||
register: npm_reinstall
|
register: npm_reinstall
|
||||||
|
|
||||||
- name: Check there is no change
|
- name: Check there is no change
|
||||||
|
@ -59,7 +59,7 @@
|
||||||
state: present
|
state: present
|
||||||
name: '{{ package }}'
|
name: '{{ package }}'
|
||||||
environment:
|
environment:
|
||||||
PATH: '{{ node_path }}:{{ ansible_env.PATH }}'
|
PATH: '{{ node_path }}:{{ ansible_env.PATH }}'
|
||||||
register: npm_fix_install
|
register: npm_fix_install
|
||||||
|
|
||||||
- name: Check result is changed and successful
|
- name: Check result is changed and successful
|
||||||
|
|
|
@ -50,8 +50,8 @@
|
||||||
- name: Copy initial config ldif file
|
- name: Copy initial config ldif file
|
||||||
become: True
|
become: True
|
||||||
copy:
|
copy:
|
||||||
src: 'files/{{ item }}'
|
src: 'files/{{ item }}'
|
||||||
dest: '/tmp/{{ item }}'
|
dest: '/tmp/{{ item }}'
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: '0644'
|
mode: '0644'
|
||||||
|
|
|
@ -100,7 +100,7 @@
|
||||||
when: ansible_os_family == "RedHat" and ansible_service_mgr != "systemd"
|
when: ansible_os_family == "RedHat" and ansible_service_mgr != "systemd"
|
||||||
|
|
||||||
- name: Initialize postgres (Debian)
|
- name: Initialize postgres (Debian)
|
||||||
shell: . /usr/share/postgresql-common/maintscripts-functions && set_system_locale && /usr/bin/pg_createcluster -u postgres {{ pg_ver }} main
|
shell: . /usr/share/postgresql-common/maintscripts-functions && set_system_locale && /usr/bin/pg_createcluster -u postgres {{ pg_ver }} main
|
||||||
args:
|
args:
|
||||||
creates: /etc/postgresql/{{ pg_ver }}/
|
creates: /etc/postgresql/{{ pg_ver }}/
|
||||||
when: ansible_os_family == 'Debian'
|
when: ansible_os_family == 'Debian'
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
|
|
||||||
- name: disable supervisord system service
|
- name: disable supervisord system service
|
||||||
service:
|
service:
|
||||||
name: '{{ supervisor_service_name }}'
|
name: '{{ supervisor_service_name }}'
|
||||||
state: stopped
|
state: stopped
|
||||||
enabled: no
|
enabled: no
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
- '{{ ansible_os_family }}.yml'
|
- '{{ ansible_os_family }}.yml'
|
||||||
- 'defaults.yml'
|
- 'defaults.yml'
|
||||||
|
|
||||||
- include_tasks: '{{ item }}'
|
- include_tasks: '{{ item }}'
|
||||||
with_first_found:
|
with_first_found:
|
||||||
- files:
|
- files:
|
||||||
- 'install_{{ ansible_distribution }}.yml' # CentOS
|
- 'install_{{ ansible_distribution }}.yml' # CentOS
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
when: ansible_os_family != 'RedHat' or ansible_distribution_major_version|int > 6
|
when: ansible_os_family != 'RedHat' or ansible_distribution_major_version|int > 6
|
||||||
|
|
||||||
always:
|
always:
|
||||||
- include_tasks: '{{ item }}'
|
- include_tasks: '{{ item }}'
|
||||||
when: ansible_os_family != 'RedHat' or ansible_distribution_major_version|int > 6
|
when: ansible_os_family != 'RedHat' or ansible_distribution_major_version|int > 6
|
||||||
with_first_found:
|
with_first_found:
|
||||||
- files:
|
- files:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
- name: start supervisord
|
- name: start supervisord
|
||||||
command: 'supervisord -c {{ remote_dir }}/supervisord.conf'
|
command: 'supervisord -c {{ remote_dir }}/supervisord.conf'
|
||||||
|
|
||||||
- name: wait_for supervisord
|
- name: wait_for supervisord
|
||||||
ansible.builtin.wait_for:
|
ansible.builtin.wait_for:
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
- name: stop supervisord
|
- name: stop supervisord
|
||||||
command: "supervisorctl -c {{ remote_dir }}/supervisord.conf {% if credentials.username %}-u {{ credentials.username }} -p {{ credentials.password }}{% endif %} shutdown"
|
command: "supervisorctl -c {{ remote_dir }}/supervisord.conf {% if credentials.username %}-u {{ credentials.username }} -p {{ credentials.password }}{% endif %} shutdown"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
- name: generate supervisor configuration
|
- name: generate supervisor configuration
|
||||||
template:
|
template:
|
||||||
src: supervisord.conf
|
src: supervisord.conf
|
||||||
dest: '{{ remote_dir }}/supervisord.conf'
|
dest: '{{ remote_dir }}/supervisord.conf'
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- import_tasks: start_supervisord.yml
|
- import_tasks: start_supervisord.yml
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
supervisorctl:
|
supervisorctl:
|
||||||
name: 'pys:py1'
|
name: 'pys:py1'
|
||||||
state: started
|
state: started
|
||||||
config: '{{ remote_dir }}/supervisord.conf'
|
config: '{{ remote_dir }}/supervisord.conf'
|
||||||
register: result
|
register: result
|
||||||
when: credentials.username == ''
|
when: credentials.username == ''
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
register: result_with_auth
|
register: result_with_auth
|
||||||
when: credentials.username != ''
|
when: credentials.username != ''
|
||||||
|
|
||||||
- command: "supervisorctl -c {{ remote_dir }}/supervisord.conf {% if credentials.username %}-u {{ credentials.username }} -p {{ credentials.password }}{% endif %} status"
|
- command: "supervisorctl -c {{ remote_dir }}/supervisord.conf {% if credentials.username %}-u {{ credentials.username }} -p {{ credentials.password }}{% endif %} status"
|
||||||
|
|
||||||
- name: check that service is started
|
- name: check that service is started
|
||||||
assert:
|
assert:
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
supervisorctl:
|
supervisorctl:
|
||||||
name: pys:py1
|
name: pys:py1
|
||||||
state: started
|
state: started
|
||||||
config: '{{ remote_dir }}/supervisord.conf'
|
config: '{{ remote_dir }}/supervisord.conf'
|
||||||
register: result
|
register: result
|
||||||
when: credentials.username == ''
|
when: credentials.username == ''
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
supervisorctl:
|
supervisorctl:
|
||||||
name: 'pys:py1'
|
name: 'pys:py1'
|
||||||
state: started
|
state: started
|
||||||
config: '{{ remote_dir }}/supervisord.conf'
|
config: '{{ remote_dir }}/supervisord.conf'
|
||||||
register: result
|
register: result
|
||||||
when: credentials.username == ''
|
when: credentials.username == ''
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@
|
||||||
supervisorctl:
|
supervisorctl:
|
||||||
name: 'pys:py1'
|
name: 'pys:py1'
|
||||||
state: started
|
state: started
|
||||||
config: '{{ remote_dir }}/supervisord_not_here.conf'
|
config: '{{ remote_dir }}/supervisord_not_here.conf'
|
||||||
register: result
|
register: result
|
||||||
failed_when: result is success or result is not failed
|
failed_when: result is success or result is not failed
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@
|
||||||
supervisorctl:
|
supervisorctl:
|
||||||
name: 'invalid'
|
name: 'invalid'
|
||||||
state: started
|
state: started
|
||||||
config: '{{ remote_dir }}/supervisord.conf'
|
config: '{{ remote_dir }}/supervisord.conf'
|
||||||
register: result
|
register: result
|
||||||
failed_when: result is skip or (result is success or result is not failed)
|
failed_when: result is skip or (result is success or result is not failed)
|
||||||
when: credentials.username == ''
|
when: credentials.username == ''
|
||||||
|
@ -127,7 +127,7 @@
|
||||||
supervisorctl:
|
supervisorctl:
|
||||||
name: 'invalid'
|
name: 'invalid'
|
||||||
state: started
|
state: started
|
||||||
config: '{{ remote_dir }}/supervisord.conf'
|
config: '{{ remote_dir }}/supervisord.conf'
|
||||||
username: '{{ credentials.username }}wrong_creds'
|
username: '{{ credentials.username }}wrong_creds'
|
||||||
password: '{{ credentials.password }}same_here'
|
password: '{{ credentials.password }}same_here'
|
||||||
register: result
|
register: result
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
register: result_with_auth
|
register: result_with_auth
|
||||||
when: credentials.username != ''
|
when: credentials.username != ''
|
||||||
|
|
||||||
- command: "supervisorctl -c {{ remote_dir }}/supervisord.conf {% if credentials.username %}-u {{ credentials.username }} -p {{ credentials.password }}{% endif %} status"
|
- command: "supervisorctl -c {{ remote_dir }}/supervisord.conf {% if credentials.username %}-u {{ credentials.username }} -p {{ credentials.password }}{% endif %} status"
|
||||||
|
|
||||||
- name: check that service is stopped
|
- name: check that service is stopped
|
||||||
assert:
|
assert:
|
||||||
|
|
|
@ -36,7 +36,7 @@ password = {{ credentials.password }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
[supervisorctl]
|
[supervisorctl]
|
||||||
serverurl=unix://{{ supervisord_sock_path.path }}/supervisord.sock
|
serverurl=unix://{{ supervisord_sock_path.path }}/supervisord.sock
|
||||||
|
|
||||||
[rpcinterface:supervisor]
|
[rpcinterface:supervisor]
|
||||||
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
|
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
|
||||||
|
|
Loading…
Reference in a new issue