diff options
author | Hiroaki Nakamura <hnakamur@gmail.com> | 2016-05-21 00:04:19 +0900 |
---|---|---|
committer | Hiroaki Nakamura <hnakamur@gmail.com> | 2016-06-26 08:57:31 +0900 |
commit | 05700edc0b5818ada9cb43bb12165c4090555417 (patch) | |
tree | d7acabbc7b6429a7cd4eeecd6bc9be67ed08db4c /cloud/lxd | |
parent | d2fa7c75da9bb592b49de8964b11b504e338ef56 (diff) | |
download | ansible-modules-extras-05700edc0b5818ada9cb43bb12165c4090555417.tar.gz |
Update document about copying files to containers
Diffstat (limited to 'cloud/lxd')
-rw-r--r-- | cloud/lxd/lxd_container.py | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/cloud/lxd/lxd_container.py b/cloud/lxd/lxd_container.py index 3a74a254..126d84a1 100644 --- a/cloud/lxd/lxd_container.py +++ b/cloud/lxd/lxd_container.py @@ -69,8 +69,8 @@ notes: 2.1, the later requires python to be installed in the container which can be done with the command module. - You can copy a file from the host to the container - with `command=lxc file push filename container_name/dir/filename` - on localhost. See the first example below. + with the Ansible `copy` and `template` module and the `lxd` connection plugin. + See the example below. - You can copy a file in the creatd container to the localhost with `command=lxc file pull container_name/dir/filename filename`. See the first example below. @@ -82,7 +82,7 @@ EXAMPLES = """ tasks: - name: Create a started container lxd_container: - name: my-ubuntu + name: mycontainer state: started config: source: @@ -92,19 +92,28 @@ EXAMPLES = """ protocol: lxd alias: "ubuntu/xenial/amd64" profiles: ["default"] - - name: Install python in the created container "nettest" - command: lxc exec my-ubuntu -- apt install -y python - - name: Copy somefile.txt to /tmp/renamed.txt in the created container "nettest" - command: lxc file push somefile.txt nettest/tmp/renamed.txt - - name: Copy /etc/hosts in the created container "nettest" to localhost with name "nettest-hosts" - command: lxc file pull nettest/etc/hosts nettest-hosts + - name: Install python in the created container "mycontainer" + command: lxc exec mycontainer -- apt install -y python + - name: Copy /etc/hosts in the created container "mycontainer" to localhost with name "mycontainer-hosts" + command: lxc file pull mycontainer/etc/hosts mycontainer-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 connection: local tasks: - name: Create a stopped container lxd_container: - name: my-ubuntu + name: mycontainer state: stopped config: source: @@ -120,7 +129,7 @@ EXAMPLES = """ tasks: - name: Restart a container lxd_container: - name: my-ubuntu + name: mycontainer state: restarted config: source: |