TG
Size: a a a
TG
TG
AD
AD
TG
TG
TG
A
- name: Set default value to db_type variable
set_fact:
db_type: "{{ lookup('env', 'ACRAEEPG_DB_TYPE') | default(db_type_default) }}"
- name: Define DB variables
set_fact:
db_port: "{{ {'postgresql':'5432', 'mysql':'3306'}[db_type] | default('') }}"
db_image: "{{ {'postgresql':'postgres:11', 'mysql':'mariadb:10'}[db_type] | default('') }}"
TASK [variables : Set default value to db_type variable] ***********************
ok: [17***********]
TASK [variables : Define DB variables] *****************************************
ok: [17***********]
TASK [variables : fail] ********************************************************
fatal: [17*********]: FAILED! => {"changed": false, "msg": "db_type is incorrect"}
A
ansible-playbook 2.9.6
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/shmel/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible-playbook
python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]
DK
- name: Set default value to db_type variable
set_fact:
db_type: "{{ lookup('env', 'ACRAEEPG_DB_TYPE') | default(db_type_default) }}"
- name: Define DB variables
set_fact:
db_port: "{{ {'postgresql':'5432', 'mysql':'3306'}[db_type] | default('') }}"
db_image: "{{ {'postgresql':'postgres:11', 'mysql':'mariadb:10'}[db_type] | default('') }}"
TASK [variables : Set default value to db_type variable] ***********************
ok: [17***********]
TASK [variables : Define DB variables] *****************************************
ok: [17***********]
TASK [variables : fail] ********************************************************
fatal: [17*********]: FAILED! => {"changed": false, "msg": "db_type is incorrect"}
A
TASK [variables : Set default value to db_type variable] **
task path: /home/shmel/git/project/ansible/roles/variables/tasks/main.yaml:18
ok: [178.*********] => {
"ansible_facts": {
"db_type": ""
},
"changed": false
}
TASK [variables : Define DB variables] **
task path: /home/shmel/git/project/ansible/roles/variables/tasks/main.yaml:22
ok: [178.*********] => {
"ansible_facts": {
"db_image": "",
"db_port": ""
},
"changed": false
}
TASK [variables : fail] **
task path: /home/shmel/git/project/ansible/roles/variables/tasks/main.yaml:27
fatal: [178.*********]: FAILED! => {
"changed": false,
"msg": "db_type is incorrect"
}
A
db_type_default: 'postgresql'
A
TG
- name: Set default value to db_type variable
set_fact:
db_type: "{{ lookup('env', 'ACRAEEPG_DB_TYPE') | default(db_type_default) }}"
- name: Define DB variables
set_fact:
db_port: "{{ {'postgresql':'5432', 'mysql':'3306'}[db_type] | default('') }}"
db_image: "{{ {'postgresql':'postgres:11', 'mysql':'mariadb:10'}[db_type] | default('') }}"
TASK [variables : Set default value to db_type variable] ***********************
ok: [17***********]
TASK [variables : Define DB variables] *****************************************
ok: [17***********]
TASK [variables : fail] ********************************************************
fatal: [17*********]: FAILED! => {"changed": false, "msg": "db_type is incorrect"}
TG
db_port: "{{ {'postgresql':'5432', 'mysql':'3306'}[db_type] | default('') }}"
A
db_port: "{{ {'postgresql':'5432', 'mysql':'3306'}[db_type] | default('') }}"
A
A
A
A