嗨,我很努力地理解为什么这段代码说目录不存在
在我看到的系统上
root@Production:~# ls -l /home/azureuser/directory-with-stuff/
并且可以看到路径存在
但是,在我的ansible代码中,统计信息告诉我该目录不存在 代码如下
Project_add\roles\common\tasks
main.yml
Developer_project_setup.yml
vars
main.yml
在Developer_project_setup.yml中,它通过main.yml中的include运行。
- name: Running make libs to build libraries
command: make libs
args:
chdir: "{ file_path_home }"
when: infra_problem_dir_check.stat.exists
- name: Running make clean for static tarballls
command: make clean all
args:
chdir: "{ file_path_home }"
when: infra_problem_dir_check.stat.exists
在vars.yml文件中
file_path_home: /home/azureuser/directory-with-stuff
我还提供了一项统计信息,但这也会使我感到惊讶
- stat:
path: "{ file_path_home }"
register: infra_problem_dir_check
我还使用以下内容尝试调试,从可以看到该文件夹的意义上来说,结果很有趣
- name: checking working directory
command: pwd
register: test
- debug: msg={{ test.stdout }}
- name: checking working directory contents
command: ls -l
register: test
- debug: msg={{ test.stdout }}
因此,当我运行剧本时,我会得到
TASK [Project_add/roles/common : stat] **************************************************************************************************************************************************************************************************************************************************************************************
ok: [client_Host_9d63] => {"changed": false, "stat": {"exists": false}}
TASK [Project_add/roles/common : checking working directory contents] *******************************************************************************************************************************************************************************************************************************************************
changed: [client_Host_9d63] => {"changed": true, "cmd": ["ls", "-l"], "delta": "0:00:00.003163", "end": "2020-03-11 23:00:50.782252", "rc": 0, "start": "2020-03-11 23:00:50.779089", "stderr": "", "stderr_lines": [], "stdout": "total 4\ndrwxr-xr-x 7 azureuser azureuser 4096 Mar 9 20:14 directory-with-stuff", "stdout_lines": ["total 4", "drwxr-xr-x 7 azureuser azureuser 4096 Mar 9 20:14 directory-with-stuff"]}
TASK [Project_add/roles/common : debug] *************************************************************************************************************************************************************************************************************************************************************************************
ok: [client_Host_9d63] => {
"msg": "total 4\ndrwxr-xr-x 7 azureuser azureuser 4096 Mar 9 20:14 directory-with-stuff"
}
TASK [Project_add/roles/common : Running make libs to build libraries] ******************************************************************************************************************************************************************************************************************************************************
skipping: [client_Host_9d63] => {"changed": false, "skip_reason": "Conditional result was False"}
TASK [Project_add/roles/common : Running make clean for static tarballls] ***************************************************************************************************************************************************************************************************************************************************
skipping: [client_Host_9d63] => {"changed": false, "skip_reason": "Conditional result was False"}
不知道为什么它说文件夹不存在,任何人都可以了解我在做什么错吗?
答案 0 :(得分:1)
我认为它的语法问题。使用double而不是single。即用'{{'代替'{“
SELECT [ta_kib_b].*,
( CASE
WHEN newkondisi IS NULL THEN kondisi
ELSE newkondisi
END ) AS lastKondisi,
( CASE
WHEN kondisisebelumta2018 IS NULL THEN kondisi
ELSE kondisisebelumta2018
END ) AS KondisiSebelumTA2018,
lastupdate,
tanggalperubahankondisiterakhir
FROM
(SELECT [ta_kib_b].*,
(SELECT TOP 1 [ta_kibbr].kondisi AS NEWKONDISI
FROM [ta_kibbr]
WHERE [ta_kib_b].kd_bidang = [ta_kibbr].kd_bidang
AND [ta_kib_b].kd_unit = [ta_kibbr].kd_unit
AND [ta_kib_b].kd_sub = [ta_kibbr].kd_sub
AND [ta_kib_b].kd_upb = [ta_kibbr].kd_upb
AND [ta_kib_b].kd_aset1 = [ta_kibbr].kd_aset1
AND [ta_kib_b].kd_aset2 = [ta_kibbr].kd_aset2
AND [ta_kib_b].kd_aset3 = [ta_kibbr].kd_aset3
AND [ta_kib_b].kd_aset4 = [ta_kibbr].kd_aset4
AND [ta_kib_b].kd_aset5 = [ta_kibbr].kd_aset5
AND [ta_kib_b].no_register = [ta_kibbr].no_register
AND kd_riwayat = 1
AND [ta_kibbr].tgl_dokumen <= '2018-12-31'
ORDER BY [ta_kibbr].tgl_dokumen DESC) AS newkondisi,
(SELECT
TOP 1 [Ta_KIBBR].Kondisi AS KondisiSebelumTA2018
FROM
[Ta_KIBBR]
WHERE
[Ta_KIB_B].Kd_Bidang = [Ta_KIBBR].Kd_Bidang
AND [Ta_KIB_B].Kd_Unit = [Ta_KIBBR].Kd_Unit
AND [Ta_KIB_B].Kd_Sub = [Ta_KIBBR].Kd_Sub
AND [Ta_KIB_B].Kd_UPB = [Ta_KIBBR].Kd_UPB
AND [Ta_KIB_B].Kd_Aset1 = [Ta_KIBBR].Kd_Aset1
AND [Ta_KIB_B].Kd_Aset2 = [Ta_KIBBR].Kd_Aset2
AND [Ta_KIB_B].Kd_Aset3 = [Ta_KIBBR].Kd_Aset3
AND [Ta_KIB_B].Kd_Aset4 = [Ta_KIBBR].Kd_Aset4
AND [Ta_KIB_B].Kd_Aset5 = [Ta_KIBBR].Kd_Aset5
AND [Ta_KIB_B].No_Register = [Ta_KIBBR].No_Register
AND Kd_Riwayat = 1
AND [Ta_KIBBR].Tgl_Dokumen <= '2017-12-31'
ORDER BY
[Ta_KIBBR].Tgl_Dokumen DESC) AS KondisiSebelumTA2018,
(SELECT
TOP 1 [Ta_KIBBR].Tgl_Dokumen AS TanggalPerubahanKondisiTerakhir
FROM
[Ta_KIBBR]
WHERE
[Ta_KIB_B].Kd_Bidang = [Ta_KIBBR].Kd_Bidang
AND [Ta_KIB_B].Kd_Unit = [Ta_KIBBR].Kd_Unit
AND [Ta_KIB_B].Kd_Sub = [Ta_KIBBR].Kd_Sub
AND [Ta_KIB_B].Kd_UPB = [Ta_KIBBR].Kd_UPB
AND [Ta_KIB_B].Kd_Aset1 = [Ta_KIBBR].Kd_Aset1
AND [Ta_KIB_B].Kd_Aset2 = [Ta_KIBBR].Kd_Aset2
AND [Ta_KIB_B].Kd_Aset3 = [Ta_KIBBR].Kd_Aset3
AND [Ta_KIB_B].Kd_Aset4 = [Ta_KIBBR].Kd_Aset4
AND [Ta_KIB_B].Kd_Aset5 = [Ta_KIBBR].Kd_Aset5
AND [Ta_KIB_B].No_Register = [Ta_KIBBR].No_Register
AND Kd_Riwayat = 1
AND [Ta_KIBBR].Tgl_Dokumen <= '2018-12-31'
ORDER BY
[Ta_KIBBR].Tgl_Dokumen DESC) AS TanggalPerubahanKondisiTerakhir,
(SELECT
TOP 1 [Ta_KIBBR].Tgl_Dokumen AS LastUpdate
FROM
[Ta_KIBBR]
WHERE
[Ta_KIB_B].Kd_Bidang = [Ta_KIBBR].Kd_Bidang
AND [Ta_KIB_B].Kd_Unit = [Ta_KIBBR].Kd_Unit
AND [Ta_KIB_B].Kd_Sub = [Ta_KIBBR].Kd_Sub
AND [Ta_KIB_B].Kd_UPB = [Ta_KIBBR].Kd_UPB
AND [Ta_KIB_B].Kd_Aset1 = [Ta_KIBBR].Kd_Aset1
AND [Ta_KIB_B].Kd_Aset2 = [Ta_KIBBR].Kd_Aset2
AND [Ta_KIB_B].Kd_Aset3 = [Ta_KIBBR].Kd_Aset3
AND [Ta_KIB_B].Kd_Aset4 = [Ta_KIBBR].Kd_Aset4
AND [Ta_KIB_B].Kd_Aset5 = [Ta_KIBBR].Kd_Aset5
AND [Ta_KIB_B].No_Register = [Ta_KIBBR].No_Register
AND [Ta_KIBBR].Tgl_Dokumen <= '2019-12-31'
ORDER BY
[Ta_KIBBR].Tgl_Dokumen DESC) AS LastUpdate
FROM ta_kib_b) as [ta_kib_b]
args:
chdir: "{{ file_path_home }}"