Details

Result

Field Value
attempts
1
changed
True
cmd
[
    "/var/lib/lxc/aio1_horizon_container-25c89891/container-first-run.sh"
]
delta
0:00:00.039782
end
2020-01-31 15:56:55.482973
rc
0
start
2020-01-31 15:56:55.443191
stderr
export CPID="$(lxc-info -Hpn aio1_horizon_container-25c89891)"

function update_backup_resolvers {
  if [[ -e "/proc/${CPID}/root/etc/resolv.conf.setup" ]]; then
    mv /proc/${CPID}/root/etc/resolv.conf.setup /proc/${CPID}/root/etc/resolv.conf
  elif [[ -e "/proc/${CPID}/root/etc/resolv.conf" ]]; then
    cp /proc/${CPID}/root/etc/resolv.conf /proc/${CPID}/root/etc/resolv.conf.setup
  fi
}

# If the setup is complete return as the process is complete
if [[ -f "/var/lib/lxc/aio1_horizon_container-25c89891/setup.complete" ]]; then
  exit 0
fi

# Backup the resolvers as the setup script is not executed within an NS.
update_backup_resolvers

# Use the host resolvers
cat /etc/resolv.conf > /proc/${CPID}/root/etc/resolv.conf

# Execute
nsenter --mount=/proc/${CPID}/ns/mnt --pid=/proc/${CPID}/ns/pid \
        --uts=/proc/${CPID}/ns/uts --ipc=/proc/${CPID}/ns/ipc \
        -- /opt/container-setup.sh

# Generate the lxc container create prep commands


# Create dir "/var/backup"
mkdir -p "/var/backup"


# Run extra commands
echo noop

# Restore the resolvers
update_backup_resolvers

# Mark the setup as complete
touch /var/lib/lxc/aio1_horizon_container-25c89891/setup.complete
stderr_lines
[
    "",
    "export CPID=\"$(lxc-info -Hpn aio1_horizon_container-25c89891)\"",
    "",
    "function update_backup_resolvers {",
    "  if [[ -e \"/proc/${CPID}/root/etc/resolv.conf.setup\" ]]; then",
    "    mv /proc/${CPID}/root/etc/resolv.conf.setup /proc/${CPID}/root/etc/resolv.conf",
    "  elif [[ -e \"/proc/${CPID}/root/etc/resolv.conf\" ]]; then",
    "    cp /proc/${CPID}/root/etc/resolv.conf /proc/${CPID}/root/etc/resolv.conf.setup",
    "  fi",
    "}",
    "",
    "# If the setup is complete return as the process is complete",
    "if [[ -f \"/var/lib/lxc/aio1_horizon_container-25c89891/setup.complete\" ]]; then",
    "  exit 0",
    "fi",
    "",
    "# Backup the resolvers as the setup script is not executed within an NS.",
    "update_backup_resolvers",
    "",
    "# Use the host resolvers",
    "cat /etc/resolv.conf > /proc/${CPID}/root/etc/resolv.conf",
    "",
    "# Execute",
    "nsenter --mount=/proc/${CPID}/ns/mnt --pid=/proc/${CPID}/ns/pid \\",
    "        --uts=/proc/${CPID}/ns/uts --ipc=/proc/${CPID}/ns/ipc \\",
    "        -- /opt/container-setup.sh",
    "",
    "# Generate the lxc container create prep commands",
    "",
    "",
    "# Create dir \"/var/backup\"",
    "mkdir -p \"/var/backup\"",
    "",
    "",
    "# Run extra commands",
    "echo noop",
    "",
    "# Restore the resolvers",
    "update_backup_resolvers",
    "",
    "# Mark the setup as complete",
    "touch /var/lib/lxc/aio1_horizon_container-25c89891/setup.complete"
]
stdout
noop
stdout_lines
[
    "noop"
]