Update document about copying files to containers
This commit is contained in:
parent
d2fa7c75da
commit
05700edc0b
1 changed files with 20 additions and 11 deletions
|
@ -69,8 +69,8 @@ notes:
|
||||||
2.1, the later requires python to be installed in the container which can
|
2.1, the later requires python to be installed in the container which can
|
||||||
be done with the command module.
|
be done with the command module.
|
||||||
- You can copy a file from the host to the container
|
- You can copy a file from the host to the container
|
||||||
with `command=lxc file push filename container_name/dir/filename`
|
with the Ansible `copy` and `template` module and the `lxd` connection plugin.
|
||||||
on localhost. See the first example below.
|
See the example below.
|
||||||
- You can copy a file in the creatd container to the localhost
|
- You can copy a file in the creatd container to the localhost
|
||||||
with `command=lxc file pull container_name/dir/filename filename`.
|
with `command=lxc file pull container_name/dir/filename filename`.
|
||||||
See the first example below.
|
See the first example below.
|
||||||
|
@ -82,7 +82,7 @@ EXAMPLES = """
|
||||||
tasks:
|
tasks:
|
||||||
- name: Create a started container
|
- name: Create a started container
|
||||||
lxd_container:
|
lxd_container:
|
||||||
name: my-ubuntu
|
name: mycontainer
|
||||||
state: started
|
state: started
|
||||||
config:
|
config:
|
||||||
source:
|
source:
|
||||||
|
@ -92,19 +92,28 @@ EXAMPLES = """
|
||||||
protocol: lxd
|
protocol: lxd
|
||||||
alias: "ubuntu/xenial/amd64"
|
alias: "ubuntu/xenial/amd64"
|
||||||
profiles: ["default"]
|
profiles: ["default"]
|
||||||
- name: Install python in the created container "nettest"
|
- name: Install python in the created container "mycontainer"
|
||||||
command: lxc exec my-ubuntu -- apt install -y python
|
command: lxc exec mycontainer -- apt install -y python
|
||||||
- name: Copy somefile.txt to /tmp/renamed.txt in the created container "nettest"
|
- name: Copy /etc/hosts in the created container "mycontainer" to localhost with name "mycontainer-hosts"
|
||||||
command: lxc file push somefile.txt nettest/tmp/renamed.txt
|
command: lxc file pull mycontainer/etc/hosts mycontainer-hosts
|
||||||
- name: Copy /etc/hosts in the created container "nettest" to localhost with name "nettest-hosts"
|
|
||||||
command: lxc file pull nettest/etc/hosts nettest-hosts
|
|
||||||
|
# Note your container must be in the inventory for the below example.
|
||||||
|
#
|
||||||
|
# [containers]
|
||||||
|
# mycontainer ansible_connection=lxd
|
||||||
|
#
|
||||||
|
- hosts:
|
||||||
|
- mycontainer
|
||||||
|
tasks:
|
||||||
|
- template: src=foo.j2 dest=/etc/bar
|
||||||
|
|
||||||
- hosts: localhost
|
- hosts: localhost
|
||||||
connection: local
|
connection: local
|
||||||
tasks:
|
tasks:
|
||||||
- name: Create a stopped container
|
- name: Create a stopped container
|
||||||
lxd_container:
|
lxd_container:
|
||||||
name: my-ubuntu
|
name: mycontainer
|
||||||
state: stopped
|
state: stopped
|
||||||
config:
|
config:
|
||||||
source:
|
source:
|
||||||
|
@ -120,7 +129,7 @@ EXAMPLES = """
|
||||||
tasks:
|
tasks:
|
||||||
- name: Restart a container
|
- name: Restart a container
|
||||||
lxd_container:
|
lxd_container:
|
||||||
name: my-ubuntu
|
name: mycontainer
|
||||||
state: restarted
|
state: restarted
|
||||||
config:
|
config:
|
||||||
source:
|
source:
|
||||||
|
|
Loading…
Reference in a new issue