Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
servers-config
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gruppo Sistemisti
servers-config
Commits
25d38b13
Commit
25d38b13
authored
Feb 27, 2018
by
Pietro Albini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lxd-container: add creation and initial configuration
parent
9f644ded
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
0 deletions
+87
-0
playbooks/roadhouse.yml
playbooks/roadhouse.yml
+10
-0
roles/lxd-container/tasks/creation.yml
roles/lxd-container/tasks/creation.yml
+39
-0
roles/lxd-container/tasks/main.yml
roles/lxd-container/tasks/main.yml
+3
-0
roles/lxd-container/templates/bootstrap-container.sh.j2
roles/lxd-container/templates/bootstrap-container.sh.j2
+35
-0
No files found.
playbooks/roadhouse.yml
View file @
25d38b13
...
@@ -27,3 +27,13 @@
...
@@ -27,3 +27,13 @@
-
role
:
lxd
-
role
:
lxd
subnet4
:
10.0.0
subnet4
:
10.0.0
subnet6
:
2001:470:b368:4242
subnet6
:
2001:470:b368:4242
-
role
:
lxd-container
name
:
spock
image
:
debian/jessie/amd64
-
role
:
lxd-container
name
:
bromuro
image
:
ubuntu/trusty/amd64
roles/lxd-container/tasks/creation.yml
0 → 100644
View file @
25d38b13
---
-
name
:
"
Create
the
{{
name
}}
container"
lxd_container
:
name
:
"
{{
name
}}"
state
:
started
source
:
type
:
image
mode
:
pull
server
:
https://images.linuxcontainers.org
protocol
:
lxd
alias
:
"
{{
image
}}"
timeout
:
600
register
:
lxd_container_created
-
block
:
-
name
:
"
Upload
the
bootstrap
script
for
the
{{
name
}}
container"
template
:
src
:
bootstrap-container.sh.j2
dest
:
"
/tmp/bootstrap-container-{{
name
}}.sh"
mode
:
0700
-
name
:
"
Execute
the
bootstrap
script
for
the
{{
name
}}
container"
command
:
"
/tmp/bootstrap-container-{{
name
}}.sh"
-
name
:
"
Delete
the
bootstrap
script
for
the
{{
name
}}
container"
file
:
path
:
"
/tmp/bootstrap-container-{{
name
}}.sh"
state
:
absent
when
:
lxd_container_created.changed
roles/lxd-container/tasks/main.yml
0 → 100644
View file @
25d38b13
---
-
include_tasks
:
creation.yml
roles/lxd-container/templates/bootstrap-container.sh.j2
0 → 100644
View file @
25d38b13
#!/bin/bash
set
-euo
pipefail
IFS
=
$'
\n\t
'
NAME
=
"{{ name }}"
ex
()
{
lxc
exec
"
${
NAME
}
"
--
$@
return
$?
}
# Install a few packages in the container
ex apt-get update
ex apt-get
install
python openssh-server
sudo
-y
# Create the "manage" user in the passwordless sudo group
if
!
ex
grep
-q
-E
"^passwordless-sudo:"
/etc/group
;
then
ex addgroup passwordless-sudo
fi
if
!
ex
grep
-q
-E
"^manage:"
/etc/passwd
;
then
ex adduser manage
--home
/home/manage
--gecos
""
--disabled-password
ex adduser manage passwordless-sudo
fi
# Allow the passwordless-sudo group to use... well... passwordless sudo?
echo
"%passwordless-sudo ALL=(ALL:ALL) NOPASSWD:ALL"
|
\
ex bash
-c
"cat >> /etc/sudoers"
# Authorize the hypervisor manage to connect to the guest manage
ex
sudo
-u
manage
mkdir
-p
/home/manage/.ssh
cat
/home/manage/.ssh/authorized_keys |
\
ex
sudo
-u
manage bash
-c
"cat > /home/manage/.ssh/authorized_keys"
ex
chmod
0600 /home/manage/.ssh/authorized_keys
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment