Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

lxc_container: snapshot clone container creation incorrectly starts the origin container #2577

Closed
odyssey4me opened this issue Jul 15, 2016 · 12 comments

Comments

@odyssey4me
Copy link

ISSUE TYPE
  • Bug Report
COMPONENT NAME

lxc_container

ANSIBLE VERSION
ansible 2.1.0.0
  config file =
  configured module search path = Default w/o overrides
CONFIGURATION

None

OS / ENVIRONMENT

I have used both Ubuntu 14.04 LTS and Ubuntu 16.04 LTS with the same results. More details in this gist: https://gist.github.com/odyssey4me/97e0edbb9e46748cdf8775b786f820b6

SUMMARY

When using the lxc_container module to create a container (overlayfs1) based on a snapshot of another container (base1) (ie lxc-clone --snapshot), instead of starting 'overlayfs1' the base container starts and thus the one that's supposed to start fails.

STEPS TO REPRODUCE

Using https://gist.github.com/odyssey4me/97e0edbb9e46748cdf8775b786f820b6#file-0-create-containers-yml you will notice the changes in state. Instead of overlayfs1 and overlayfs2 being in a started state (with base1 and base2 in a stopped state), the result is the opposite.

The playbook below does a comparative test using the module and the CLI.

- name: Create containers via host target
  hosts: localhost
  tasks:

    - name: Clean up previous tests
      lxc_container:
        name: "{{ item }}"
        state: absent
      with_items:
        - overlayfs1
        - base1
        - overlayfs2
        - base2

    - name: Create container base1
      lxc_container:
        name: base1
        template: download
        state: stopped
        backing_store: dir
        template_options: --dist ubuntu --release trusty --arch amd64

    - name: Check state of base1
      command: lxc-info -n base1

    - name: Create container overlay1
      lxc_container:
        name: base1
        clone_snapshot: yes
        clone_name: overlayfs1
        state: started
        backing_store: overlayfs

    - name: Check state of base1
      command: lxc-info -n base1

    - name: Check state of overlayfs1
      command: lxc-info -n overlayfs1

    - name: Create container base2
      command: lxc-create --name=base2 --template=download -- --dist ubuntu --release trusty --arch amd64

    - name: Check state of base2
      command: lxc-info -n base2

    - name: Create container overlayfs2
      command: lxc-clone --snapshot --backingstore overlayfs --orig base2 --new overlayfs2

    - name: Start container overlayfs2
      command: lxc-start --name overlayfs2

    - name: Check state of base2
      command: lxc-info -n base2

    - name: Check state of overlayfs2
      command: lxc-info -n overlayfs2
EXPECTED RESULTS

The container overlayfs1 and overlayfs2 should be running, while the base containers should be stopped.

ACTUAL RESULTS

The container base1 and overlayfs2 are running. The container overlayfs1 tried to start, but failed because the base was running.

root@lxc-xenial1:~# ansible-playbook -i inventory create-containers.yml -vvvv
No config file found; using defaults
Loaded callback default of type stdout, v2.0

PLAYBOOK: create-containers.yml ************************************************
1 plays in create-containers.yml

PLAY [Create containers via host target] ***************************************

TASK [setup] *******************************************************************
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1468610711.39-163986335105665 `" && echo ansible-tmp-1468610711.39-163986335105665="` echo $HOME/.ansible/tmp/ansible-tmp-1468610711.39-163986335105665 `" ) && sleep 0'
<localhost> PUT /tmp/tmpkQAhoA TO /root/.ansible/tmp/ansible-tmp-1468610711.39-163986335105665/setup
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1468610711.39-163986335105665/setup; rm -rf "/root/.ansible/tmp/ansible-tmp-1468610711.39-163986335105665/" > /dev/null 2>&1 && sleep 0'
ok: [localhost]

TASK [Clean up previous tests] *************************************************
task path: /root/create-containers.yml:5
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1468610712.07-85439717723482 `" && echo ansible-tmp-1468610712.07-85439717723482="` echo $HOME/.ansible/tmp/ansible-tmp-1468610712.07-85439717723482 `" ) && sleep 0'
<localhost> PUT /tmp/tmpDoUxEA TO /root/.ansible/tmp/ansible-tmp-1468610712.07-85439717723482/lxc_container
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1468610712.07-85439717723482/lxc_container; rm -rf "/root/.ansible/tmp/ansible-tmp-1468610712.07-85439717723482/" > /dev/null 2>&1 && sleep 0'
ok: [localhost] => (item=overlayfs1) => {"changed": false, "invocation": {"module_args": {"archive": false, "archive_compression": "gzip", "archive_path": null, "backing_store": "dir", "clone_name": null, "clone_snapshot": false, "config": null, "container_command": null, "container_config": null, "container_log": false, "container_log_level": "INFO", "directory": null, "fs_size": "5G", "fs_type": "ext4", "lv_name": "overlayfs1", "lxc_path": null, "name": "overlayfs1", "state": "absent", "template": "ubuntu", "template_options": null, "thinpool": null, "vg_name": "lxc", "zfs_root": null}, "module_name": "lxc_container"}, "item": "overlayfs1", "lxc_container": {"init_pid": -1, "interfaces": [], "ips": [], "name": "overlayfs1", "state": "absent"}}
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1468610712.25-187640896335277 `" && echo ansible-tmp-1468610712.25-187640896335277="` echo $HOME/.ansible/tmp/ansible-tmp-1468610712.25-187640896335277 `" ) && sleep 0'
<localhost> PUT /tmp/tmpb7FZXw TO /root/.ansible/tmp/ansible-tmp-1468610712.25-187640896335277/lxc_container
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1468610712.25-187640896335277/lxc_container; rm -rf "/root/.ansible/tmp/ansible-tmp-1468610712.25-187640896335277/" > /dev/null 2>&1 && sleep 0'
ok: [localhost] => (item=base1) => {"changed": false, "invocation": {"module_args": {"archive": false, "archive_compression": "gzip", "archive_path": null, "backing_store": "dir", "clone_name": null, "clone_snapshot": false, "config": null, "container_command": null, "container_config": null, "container_log": false, "container_log_level": "INFO", "directory": null, "fs_size": "5G", "fs_type": "ext4", "lv_name": "base1", "lxc_path": null, "name": "base1", "state": "absent", "template": "ubuntu", "template_options": null, "thinpool": null, "vg_name": "lxc", "zfs_root": null}, "module_name": "lxc_container"}, "item": "base1", "lxc_container": {"init_pid": -1, "interfaces": [], "ips": [], "name": "base1", "state": "absent"}}
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1468610712.45-240294886609476 `" && echo ansible-tmp-1468610712.45-240294886609476="` echo $HOME/.ansible/tmp/ansible-tmp-1468610712.45-240294886609476 `" ) && sleep 0'
<localhost> PUT /tmp/tmp7lByo5 TO /root/.ansible/tmp/ansible-tmp-1468610712.45-240294886609476/lxc_container
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1468610712.45-240294886609476/lxc_container; rm -rf "/root/.ansible/tmp/ansible-tmp-1468610712.45-240294886609476/" > /dev/null 2>&1 && sleep 0'
ok: [localhost] => (item=overlayfs2) => {"changed": false, "invocation": {"module_args": {"archive": false, "archive_compression": "gzip", "archive_path": null, "backing_store": "dir", "clone_name": null, "clone_snapshot": false, "config": null, "container_command": null, "container_config": null, "container_log": false, "container_log_level": "INFO", "directory": null, "fs_size": "5G", "fs_type": "ext4", "lv_name": "overlayfs2", "lxc_path": null, "name": "overlayfs2", "state": "absent", "template": "ubuntu", "template_options": null, "thinpool": null, "vg_name": "lxc", "zfs_root": null}, "module_name": "lxc_container"}, "item": "overlayfs2", "lxc_container": {"init_pid": -1, "interfaces": [], "ips": [], "name": "overlayfs2", "state": "absent"}}
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1468610712.63-254367127523273 `" && echo ansible-tmp-1468610712.63-254367127523273="` echo $HOME/.ansible/tmp/ansible-tmp-1468610712.63-254367127523273 `" ) && sleep 0'
<localhost> PUT /tmp/tmpkQCnTD TO /root/.ansible/tmp/ansible-tmp-1468610712.63-254367127523273/lxc_container
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1468610712.63-254367127523273/lxc_container; rm -rf "/root/.ansible/tmp/ansible-tmp-1468610712.63-254367127523273/" > /dev/null 2>&1 && sleep 0'
ok: [localhost] => (item=base2) => {"changed": false, "invocation": {"module_args": {"archive": false, "archive_compression": "gzip", "archive_path": null, "backing_store": "dir", "clone_name": null, "clone_snapshot": false, "config": null, "container_command": null, "container_config": null, "container_log": false, "container_log_level": "INFO", "directory": null, "fs_size": "5G", "fs_type": "ext4", "lv_name": "base2", "lxc_path": null, "name": "base2", "state": "absent", "template": "ubuntu", "template_options": null, "thinpool": null, "vg_name": "lxc", "zfs_root": null}, "module_name": "lxc_container"}, "item": "base2", "lxc_container": {"init_pid": -1, "interfaces": [], "ips": [], "name": "base2", "state": "absent"}}

TASK [Create container base1] **************************************************
task path: /root/create-containers.yml:15
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1468610712.82-83067903917603 `" && echo ansible-tmp-1468610712.82-83067903917603="` echo $HOME/.ansible/tmp/ansible-tmp-1468610712.82-83067903917603 `" ) && sleep 0'
<localhost> PUT /tmp/tmpCKnGWI TO /root/.ansible/tmp/ansible-tmp-1468610712.82-83067903917603/lxc_container
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1468610712.82-83067903917603/lxc_container; rm -rf "/root/.ansible/tmp/ansible-tmp-1468610712.82-83067903917603/" > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {"changed": true, "invocation": {"module_args": {"archive": false, "archive_compression": "gzip", "archive_path": null, "backing_store": "dir", "clone_name": null, "clone_snapshot": false, "config": null, "container_command": null, "container_config": null, "container_log": false, "container_log_level": "INFO", "directory": null, "fs_size": "5G", "fs_type": "ext4", "lv_name": "base1", "lxc_path": null, "name": "base1", "state": "stopped", "template": "download", "template_options": "--dist ubuntu --release trusty --arch amd64", "thinpool": null, "vg_name": "lxc", "zfs_root": null}, "module_name": "lxc_container"}, "lxc_container": {"init_pid": -1, "interfaces": [], "ips": [], "name": "base1", "state": "stopped"}}

TASK [Check state of base1] ****************************************************
task path: /root/create-containers.yml:23
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1468610722.41-225738658388606 `" && echo ansible-tmp-1468610722.41-225738658388606="` echo $HOME/.ansible/tmp/ansible-tmp-1468610722.41-225738658388606 `" ) && sleep 0'
<localhost> PUT /tmp/tmpjSt_Zx TO /root/.ansible/tmp/ansible-tmp-1468610722.41-225738658388606/command
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1468610722.41-225738658388606/command; rm -rf "/root/.ansible/tmp/ansible-tmp-1468610722.41-225738658388606/" > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {"changed": true, "cmd": ["lxc-info", "-n", "base1"], "delta": "0:00:00.004095", "end": "2016-07-15 19:25:22.562648", "invocation": {"module_args": {"_raw_params": "lxc-info -n base1", "_uses_shell": false, "chdir": null, "creates": null, "executable": null, "removes": null, "warn": true}, "module_name": "command"}, "rc": 0, "start": "2016-07-15 19:25:22.558553", "stderr": "", "stdout": "Name:           base1\nState:          STOPPED", "stdout_lines": ["Name:           base1", "State:          STOPPED"], "warnings": []}

TASK [Create container overlay1] ***********************************************
task path: /root/create-containers.yml:26
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1468610722.61-271576512150134 `" && echo ansible-tmp-1468610722.61-271576512150134="` echo $HOME/.ansible/tmp/ansible-tmp-1468610722.61-271576512150134 `" ) && sleep 0'
<localhost> PUT /tmp/tmpi7oEEz TO /root/.ansible/tmp/ansible-tmp-1468610722.61-271576512150134/lxc_container
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1468610722.61-271576512150134/lxc_container; rm -rf "/root/.ansible/tmp/ansible-tmp-1468610722.61-271576512150134/" > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {"changed": true, "invocation": {"module_args": {"archive": false, "archive_compression": "gzip", "archive_path": null, "backing_store": "overlayfs", "clone_name": "overlayfs1", "clone_snapshot": true, "config": null, "container_command": null, "container_config": null, "container_log": false, "container_log_level": "INFO", "directory": null, "fs_size": "5G", "fs_type": "ext4", "lv_name": "base1", "lxc_path": null, "name": "base1", "state": "started", "template": "ubuntu", "template_options": null, "thinpool": null, "vg_name": "lxc", "zfs_root": null}, "module_name": "lxc_container"}, "lxc_container": {"cloned": true, "init_pid": 30408, "interfaces": ["eth0", "lo"], "ips": [], "name": "base1", "state": "running"}}

TASK [Check state of base1] ****************************************************
task path: /root/create-containers.yml:34
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1468610724.67-62785259699531 `" && echo ansible-tmp-1468610724.67-62785259699531="` echo $HOME/.ansible/tmp/ansible-tmp-1468610724.67-62785259699531 `" ) && sleep 0'
<localhost> PUT /tmp/tmpOHU5Ko TO /root/.ansible/tmp/ansible-tmp-1468610724.67-62785259699531/command
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1468610724.67-62785259699531/command; rm -rf "/root/.ansible/tmp/ansible-tmp-1468610724.67-62785259699531/" > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {"changed": true, "cmd": ["lxc-info", "-n", "base1"], "delta": "0:00:00.007382", "end": "2016-07-15 19:25:24.830743", "invocation": {"module_args": {"_raw_params": "lxc-info -n base1", "_uses_shell": false, "chdir": null, "creates": null, "executable": null, "removes": null, "warn": true}, "module_name": "command"}, "rc": 0, "start": "2016-07-15 19:25:24.823361", "stderr": "", "stdout": "Name:           base1\nState:          RUNNING\nPID:            30408\nCPU use:        0.54 seconds\nBlkIO use:      128.00 KiB\nMemory use:     3.21 MiB\nKMem use:       0 bytes\nLink:           veth3EIQJU\n TX bytes:      168 bytes\n RX bytes:      180 bytes\n Total bytes:   348 bytes", "stdout_lines": ["Name:           base1", "State:          RUNNING", "PID:            30408", "CPU use:        0.54 seconds", "BlkIO use:      128.00 KiB", "Memory use:     3.21 MiB", "KMem use:       0 bytes", "Link:           veth3EIQJU", " TX bytes:      168 bytes", " RX bytes:      180 bytes", " Total bytes:   348 bytes"], "warnings": []}

TASK [Check state of overlayfs1] ***********************************************
task path: /root/create-containers.yml:37
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1468610724.87-52326584062516 `" && echo ansible-tmp-1468610724.87-52326584062516="` echo $HOME/.ansible/tmp/ansible-tmp-1468610724.87-52326584062516 `" ) && sleep 0'
<localhost> PUT /tmp/tmpBWLeQY TO /root/.ansible/tmp/ansible-tmp-1468610724.87-52326584062516/command
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1468610724.87-52326584062516/command; rm -rf "/root/.ansible/tmp/ansible-tmp-1468610724.87-52326584062516/" > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {"changed": true, "cmd": ["lxc-info", "-n", "overlayfs1"], "delta": "0:00:00.004219", "end": "2016-07-15 19:25:25.034033", "invocation": {"module_args": {"_raw_params": "lxc-info -n overlayfs1", "_uses_shell": false, "chdir": null, "creates": null, "executable": null, "removes": null, "warn": true}, "module_name": "command"}, "rc": 0, "start": "2016-07-15 19:25:25.029814", "stderr": "", "stdout": "Name:           overlayfs1\nState:          STOPPED", "stdout_lines": ["Name:           overlayfs1", "State:          STOPPED"], "warnings": []}

TASK [Create container base2] **************************************************
task path: /root/create-containers.yml:40
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1468610725.08-277848135836061 `" && echo ansible-tmp-1468610725.08-277848135836061="` echo $HOME/.ansible/tmp/ansible-tmp-1468610725.08-277848135836061 `" ) && sleep 0'
<localhost> PUT /tmp/tmpASWeTJ TO /root/.ansible/tmp/ansible-tmp-1468610725.08-277848135836061/command
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1468610725.08-277848135836061/command; rm -rf "/root/.ansible/tmp/ansible-tmp-1468610725.08-277848135836061/" > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {"changed": true, "cmd": ["lxc-create", "--name=base2", "--template=download", "--", "--dist", "ubuntu", "--release", "trusty", "--arch", "amd64"], "delta": "0:00:09.418855", "end": "2016-07-15 19:25:34.655951", "invocation": {"module_args": {"_raw_params": "lxc-create --name=base2 --template=download -- --dist ubuntu --release trusty --arch amd64", "_uses_shell": false, "chdir": null, "creates": null, "executable": null, "removes": null, "warn": true}, "module_name": "command"}, "rc": 0, "start": "2016-07-15 19:25:25.237096", "stderr": "", "stdout": "Using image from local cache\nUnpacking the rootfs\n\n---\nYou just created an Ubuntu container (release=trusty, arch=amd64, variant=default)\n\nTo enable sshd, run: apt-get install openssh-server\n\nFor security reason, container images ship without user accounts\nand without a root password.\n\nUse lxc-attach or chroot directly into the rootfs to set a root password\nor create user accounts.", "stdout_lines": ["Using image from local cache", "Unpacking the rootfs", "", "---", "You just created an Ubuntu container (release=trusty, arch=amd64, variant=default)", "", "To enable sshd, run: apt-get install openssh-server", "", "For security reason, container images ship without user accounts", "and without a root password.", "", "Use lxc-attach or chroot directly into the rootfs to set a root password", "or create user accounts."], "warnings": []}

TASK [Check state of base2] ****************************************************
task path: /root/create-containers.yml:43
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1468610734.7-39936234861778 `" && echo ansible-tmp-1468610734.7-39936234861778="` echo $HOME/.ansible/tmp/ansible-tmp-1468610734.7-39936234861778 `" ) && sleep 0'
<localhost> PUT /tmp/tmpvHHdSN TO /root/.ansible/tmp/ansible-tmp-1468610734.7-39936234861778/command
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1468610734.7-39936234861778/command; rm -rf "/root/.ansible/tmp/ansible-tmp-1468610734.7-39936234861778/" > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {"changed": true, "cmd": ["lxc-info", "-n", "base2"], "delta": "0:00:00.004381", "end": "2016-07-15 19:25:34.856930", "invocation": {"module_args": {"_raw_params": "lxc-info -n base2", "_uses_shell": false, "chdir": null, "creates": null, "executable": null, "removes": null, "warn": true}, "module_name": "command"}, "rc": 0, "start": "2016-07-15 19:25:34.852549", "stderr": "", "stdout": "Name:           base2\nState:          STOPPED", "stdout_lines": ["Name:           base2", "State:          STOPPED"], "warnings": []}

TASK [Create container overlayfs2] *********************************************
task path: /root/create-containers.yml:46
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1468610734.89-236288139419663 `" && echo ansible-tmp-1468610734.89-236288139419663="` echo $HOME/.ansible/tmp/ansible-tmp-1468610734.89-236288139419663 `" ) && sleep 0'
<localhost> PUT /tmp/tmpH1MCEQ TO /root/.ansible/tmp/ansible-tmp-1468610734.89-236288139419663/command
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1468610734.89-236288139419663/command; rm -rf "/root/.ansible/tmp/ansible-tmp-1468610734.89-236288139419663/" > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {"changed": true, "cmd": ["lxc-clone", "--snapshot", "--backingstore", "overlayfs", "--orig", "base2", "--new", "overlayfs2"], "delta": "0:00:00.035715", "end": "2016-07-15 19:25:35.079051", "invocation": {"module_args": {"_raw_params": "lxc-clone --snapshot --backingstore overlayfs --orig base2 --new overlayfs2", "_uses_shell": false, "chdir": null, "creates": null, "executable": null, "removes": null, "warn": true}, "module_name": "command"}, "rc": 0, "start": "2016-07-15 19:25:35.043336", "stderr": "lxc-clone is deprecated in favor of lxc-copy.", "stdout": "Created container overlayfs2 as snapshot of base2", "stdout_lines": ["Created container overlayfs2 as snapshot of base2"], "warnings": []}

TASK [Start container overlayfs2] **********************************************
task path: /root/create-containers.yml:49
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1468610735.12-118602587099220 `" && echo ansible-tmp-1468610735.12-118602587099220="` echo $HOME/.ansible/tmp/ansible-tmp-1468610735.12-118602587099220 `" ) && sleep 0'
<localhost> PUT /tmp/tmpOn0cIP TO /root/.ansible/tmp/ansible-tmp-1468610735.12-118602587099220/command
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1468610735.12-118602587099220/command; rm -rf "/root/.ansible/tmp/ansible-tmp-1468610735.12-118602587099220/" > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {"changed": true, "cmd": ["lxc-start", "--name", "overlayfs2"], "delta": "0:00:00.113790", "end": "2016-07-15 19:25:35.381053", "invocation": {"module_args": {"_raw_params": "lxc-start --name overlayfs2", "_uses_shell": false, "chdir": null, "creates": null, "executable": null, "removes": null, "warn": true}, "module_name": "command"}, "rc": 0, "start": "2016-07-15 19:25:35.267263", "stderr": "", "stdout": "", "stdout_lines": [], "warnings": []}

TASK [Check state of base2] ****************************************************
task path: /root/create-containers.yml:52
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1468610735.42-115944933709368 `" && echo ansible-tmp-1468610735.42-115944933709368="` echo $HOME/.ansible/tmp/ansible-tmp-1468610735.42-115944933709368 `" ) && sleep 0'
<localhost> PUT /tmp/tmpUJItZB TO /root/.ansible/tmp/ansible-tmp-1468610735.42-115944933709368/command
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1468610735.42-115944933709368/command; rm -rf "/root/.ansible/tmp/ansible-tmp-1468610735.42-115944933709368/" > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {"changed": true, "cmd": ["lxc-info", "-n", "base2"], "delta": "0:00:00.004206", "end": "2016-07-15 19:25:35.564378", "invocation": {"module_args": {"_raw_params": "lxc-info -n base2", "_uses_shell": false, "chdir": null, "creates": null, "executable": null, "removes": null, "warn": true}, "module_name": "command"}, "rc": 0, "start": "2016-07-15 19:25:35.560172", "stderr": "", "stdout": "Name:           base2\nState:          STOPPED", "stdout_lines": ["Name:           base2", "State:          STOPPED"], "warnings": []}

TASK [Check state of overlayfs2] ***********************************************
task path: /root/create-containers.yml:55
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1468610735.61-103782671782842 `" && echo ansible-tmp-1468610735.61-103782671782842="` echo $HOME/.ansible/tmp/ansible-tmp-1468610735.61-103782671782842 `" ) && sleep 0'
<localhost> PUT /tmp/tmpoDyZBZ TO /root/.ansible/tmp/ansible-tmp-1468610735.61-103782671782842/command
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1468610735.61-103782671782842/command; rm -rf "/root/.ansible/tmp/ansible-tmp-1468610735.61-103782671782842/" > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {"changed": true, "cmd": ["lxc-info", "-n", "overlayfs2"], "delta": "0:00:00.007050", "end": "2016-07-15 19:25:35.759251", "invocation": {"module_args": {"_raw_params": "lxc-info -n overlayfs2", "_uses_shell": false, "chdir": null, "creates": null, "executable": null, "removes": null, "warn": true}, "module_name": "command"}, "rc": 0, "start": "2016-07-15 19:25:35.752201", "stderr": "", "stdout": "Name:           overlayfs2\nState:          RUNNING\nPID:            32287\nCPU use:        0.82 seconds\nBlkIO use:      128.00 KiB\nMemory use:     3.64 MiB\nKMem use:       0 bytes\nLink:           veth5A5U1B\n TX bytes:      168 bytes\n RX bytes:      168 bytes\n Total bytes:   336 bytes", "stdout_lines": ["Name:           overlayfs2", "State:          RUNNING", "PID:            32287", "CPU use:        0.82 seconds", "BlkIO use:      128.00 KiB", "Memory use:     3.64 MiB", "KMem use:       0 bytes", "Link:           veth5A5U1B", " TX bytes:      168 bytes", " RX bytes:      168 bytes", " Total bytes:   336 bytes"], "warnings": []}

PLAY RECAP *********************************************************************
localhost                  : ok=13   changed=11   unreachable=0    failed=0
@odyssey4me
Copy link
Author

@cloudnull Note that this issue is now fully replicated.

@odyssey4me odyssey4me changed the title LXC snapshot clone container creation incorrectly starts the origin container lxc_container: snapshot clone container creation incorrectly starts the origin container Jul 21, 2016
@ansibot
Copy link

ansibot commented Aug 4, 2016

@cloudnull, ping. This issue is still waiting on your response.
click here for bot help

@cloudnull
Copy link
Contributor

I'm now working on this issue and hope to have a fix in soon-ish.

@ansibot
Copy link

ansibot commented Sep 11, 2016

@cloudnull, ping. This issue is still waiting on your response.
click here for bot help

@morfeush22
Copy link

It seems that option state is bound to container specified by name. Additionally, state is by default started. The possible workaround would be to explicitly force stop state on base container during clone step, and later start cloned container in another task:

- name: Create container overlay1
  lxc_container:
    name: base1
    clone_snapshot: yes
    clone_name: overlayfs1
    state: stopped
    backing_store: overlayfs
    
- name: Start container overlay1
  lxc_container:
    name: overlayfs1
    state: started

@odyssey4me
Copy link
Author

@morfeush22 Yeah, that makes sense as a workaround. Thanks - we're doing something similar, but due to #2691 we're using the CLI commands anyway.

@ansibot
Copy link

ansibot commented Oct 6, 2016

@cloudnull, ping. This issue is still waiting on your response.
click here for bot help

2 similar comments
@ansibot
Copy link

ansibot commented Oct 22, 2016

@cloudnull, ping. This issue is still waiting on your response.
click here for bot help

@ansibot
Copy link

ansibot commented Nov 6, 2016

@cloudnull, ping. This issue is still waiting on your response.
click here for bot help

@ansibot
Copy link

ansibot commented Nov 22, 2016

@cloudnull, ping. This issue is still waiting on your response.
click here for bot help

@ansibot
Copy link

ansibot commented Dec 6, 2016

This repository has been locked. All new issues and pullrequests should be filed in https://github.com/ansible/ansible

Please read through the repomerge page in the dev guide. The guide contains links to tools which automatically move your issue or pullrequest to the ansible/ansible repo.

@ansibot
Copy link

ansibot commented Sep 11, 2017

This issue was migrated to ansible/ansible#29336

@ansibot ansibot closed this as completed Sep 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants