如何使用ansible挂载单个文件?
How do I mount single files using ansible?
我在远程主机上有一个目录,我想将其装载到 docker 容器中。这个目录的问题是,它的文件和它本身需要一个特定的所有者和组。首先,我尝试过:
...some code...
- name: setup jitsi-meet volumes
file:
path: "{{ item }}"
state: directory
owner: 999 # jvb / jicofo in videobrige / jicofo container
group: 1000 # jitsi in videobrige / jicofo container
mode: 0755
with_items:
- "{{ CONFIG }}/jicofo"
- "{{ CONFIG }}/jvb"
...some code...
# Video bridge
- name: run jitsi-meet jvb image
docker_container:
name: jitsi-jvb
........
volumes:
"{{ CONFIG }}/jvb:/config"
........
...some code...
Ansible 确实使用所需的所有者和组递归地创建卷。所以{{ CONFIG }}/jvb
及其内容有999:1000
(jvb:jitsi
)。但是,无论出于何种原因,在挂载期间只有 /config
具有所需的所有者和组(999:1000
或 jvb:jitsi
),而 /config
的内容仍然具有 root:root
。然后,我尝试逐个文件挂载(见下文),但 ansible 拒绝让我这样做。有人知道如何解决这个问题吗?
# Video bridge
- name: run jitsi-meet jvb image
docker_container:
name: jitsi-jvb
..........
volumes:
"{{ CONFIG }}/jvb:/config"
"{{ CONFIG }}/jvb/logging.properties:/config/logging.properties"
"{{ CONFIG }}/jvb/sip-communicator.properties:/config/sip-communicator.properties"
错误是:
ERROR! Syntax Error while loading YAML.
did not find expected key
The error appears to have been in '/FAKEPATH/docker-container-jitsi.yml': line 56, column 7, but may be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
"{{ CONFIG }}/jvb:/config"
"{{ CONFIG }}/jvb/logging.properties:/config/logging.properties"
^ here
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:
with_items:
- {{ foo }}
Should be written as:
with_items:
- "{{ foo }}"
对我来说这似乎是一个简单的语法问题。
您的 volumeList 的破折号丢失了:
...
volumes:
- "{{ CONFIG }}/jvb:/config"
- "{{ CONFIG }}/jvb/logging.properties:/config/logging.properties"
- "{{ CONFIG }}/jvb/sip-communicator.properties:/config/sip-communicator.properties"
...
我在远程主机上有一个目录,我想将其装载到 docker 容器中。这个目录的问题是,它的文件和它本身需要一个特定的所有者和组。首先,我尝试过:
...some code...
- name: setup jitsi-meet volumes
file:
path: "{{ item }}"
state: directory
owner: 999 # jvb / jicofo in videobrige / jicofo container
group: 1000 # jitsi in videobrige / jicofo container
mode: 0755
with_items:
- "{{ CONFIG }}/jicofo"
- "{{ CONFIG }}/jvb"
...some code...
# Video bridge
- name: run jitsi-meet jvb image
docker_container:
name: jitsi-jvb
........
volumes:
"{{ CONFIG }}/jvb:/config"
........
...some code...
Ansible 确实使用所需的所有者和组递归地创建卷。所以{{ CONFIG }}/jvb
及其内容有999:1000
(jvb:jitsi
)。但是,无论出于何种原因,在挂载期间只有 /config
具有所需的所有者和组(999:1000
或 jvb:jitsi
),而 /config
的内容仍然具有 root:root
。然后,我尝试逐个文件挂载(见下文),但 ansible 拒绝让我这样做。有人知道如何解决这个问题吗?
# Video bridge
- name: run jitsi-meet jvb image
docker_container:
name: jitsi-jvb
..........
volumes:
"{{ CONFIG }}/jvb:/config"
"{{ CONFIG }}/jvb/logging.properties:/config/logging.properties"
"{{ CONFIG }}/jvb/sip-communicator.properties:/config/sip-communicator.properties"
错误是:
ERROR! Syntax Error while loading YAML.
did not find expected key
The error appears to have been in '/FAKEPATH/docker-container-jitsi.yml': line 56, column 7, but may be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
"{{ CONFIG }}/jvb:/config"
"{{ CONFIG }}/jvb/logging.properties:/config/logging.properties"
^ here
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:
with_items:
- {{ foo }}
Should be written as:
with_items:
- "{{ foo }}"
对我来说这似乎是一个简单的语法问题。 您的 volumeList 的破折号丢失了:
...
volumes:
- "{{ CONFIG }}/jvb:/config"
- "{{ CONFIG }}/jvb/logging.properties:/config/logging.properties"
- "{{ CONFIG }}/jvb/sip-communicator.properties:/config/sip-communicator.properties"
...