Hello!
Trying to install run ansible-playbook (kubespray) through a proxy.
Here specify the proxy server: https://github.com/kubernetes-incubator/kubespray/blob/master/inventory/sample/group_vars/all/all.yml#L52
Added to the longing Install packages requirements for bootstrap
environment: "{{proxy_env}}"
Throws an error
`
Trying other mirror.
`
If a yaml file to do this task
`
-
name: echo Variables
shell: “echo $http_proxy $https_proxy”
register: shell_echo_proxy
environment: “{{proxy_env}}” -
debug:
var: shell_echo_proxy.stdout
`
The will here is such a mistake:
`
The field ‘environment’ has an invalid value, which includes an undefined variable. The error was: ‘ansible.vars.hostvars.HostVarsVars object’ has no attribute ‘ansible_default_ipv4’
The error appears to have been in ‘/home/user/kubespray/roles/bootstrap-os/tasks/bootstrap-centos.yml’: line 17, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: echo Variables
^ here
`
Try other code
`
-
name: echo Variables
shell: “echo $http_proxy $https_proxy”
register: shell_echo_proxy
environment: -
PATH: “/sbin:/usr/sbin:{{ ansible_env.PATH }}”
“{{proxy_env}}” -
debug:
var: shell_echo_proxy.stdout
TASK [bootstrap-os : include_tasks] *************************************************************************************************************
Sunday 04 November 2018 19:11:37 +0600 (0:00:00.185) 0:00:08.531 *******
fatal: [kuber1]: FAILED! => {“reason”: “Syntax Error while loading YAML.\n expected , but found ‘?’\n\nThe error appears to have been in ‘/home/user/kubespray/roles/bootstrap-os/tasks/bootstrap-centos.yml’: line 22, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n - PATH: "/sbin:/usr/sbin:{{ ansible_env.PATH }}"\n proxy_env: "{{proxy_env}}"\n ^ here\nWe could be wrong, but this one looks like it might be an issue with\nmissing quotes. Always quote template expression brackets when they\nstart a value. For instance:\n\n with_items:\n - {{ foo }}\n\nShould be written as:\n\n with_items:\n - "{{ foo }}"\n”}
`
Try other code
`
- name: echo Variables
shell: “echo $http_proxy $https_proxy”
register: shell_echo_proxy
environment:
-
PATH: “/sbin:/usr/sbin:{{ ansible_env.PATH }}”
-
proxy_env: “{{proxy_env}}”
-
debug:
var: shell_echo_proxy.stdout
TASK [bootstrap-os : debug] *********************************************************************************************************************
Sunday 04 November 2018 19:09:05 +0600 (0:00:02.309) 0:00:15.026 *******
ok: [kuber3] => {
“shell_echo_proxy.stdout”: “”
}
ok: [kuber1] => {
“shell_echo_proxy.stdout”: “”
}
ok: [kuber2] => {
“shell_echo_proxy.stdout”: “”
}
`
Try other code
`
-
name: echo Variables
shell: “echo $http_proxy $https_proxy”
register: shell_echo_proxy
environment: {PATH: “{{ ansible_env.PATH }}:{{ bin_dir }}”,“{{proxy_env}}”} -
debug:
var: shell_echo_proxy.stdout
TASK [bootstrap-os : echo Variables] ************************************************************************************************************
Sunday 04 November 2018 19:13:39 +0600 (0:00:01.830) 0:00:12.664 *******
fatal: [kuber1]: FAILED! => {“changed”: false, “module_stderr”: “Shared connection to 172.16.149.93 closed.\r\n”, “module_stdout”:
“/bin/sh: {{proxy_env}}=None: command not found\r\n”, “msg”: “MODULE FAILURE”, “rc”: 127}
`
Try other code
`
-
name: echo Variables
shell: “echo $http_proxy $https_proxy”
register: shell_echo_proxy
vars:
“{{proxy_env}}”
environment: -
PATH: “/sbin:/usr/sbin:{{ ansible_env.PATH }}”
-
debug:
var: shell_echo_proxy.stdout
TASK [bootstrap-os : include_tasks] *************************************************************************************************************
Sunday 04 November 2018 19:16:49 +0600 (0:00:00.192) 0:00:08.732 *******
fatal: [kuber1]: FAILED! => {“reason”: “Vars in a Task must be specified as a dictionary, or a list of dictionaries\n\nThe error appears to have been in ‘/home/user/kubespray/roles/bootstrap-os/tasks/bootstrap-centos.yml’: line 21, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n vars:\n "{{proxy_env}}"\n ^ here\nWe could be wrong, but this one looks like it might be an issue with\nmissing quotes. Always quote template expression brackets when they\nstart a value. For instance:\n\n with_items:\n - {{ foo }}\n\nShould be written as:\n\n with_items:\n - "{{ foo }}"\n”}
fatal: [kuber2]: FAILED! => {“reason”: "Vars in a Task must be specified as a dictionary, or a li
`