►
From YouTube: Using Ansible and GitLab for Infrastructure as Code
Description
Quick demo of GitLab managing and executing Ansible playbooks using the CI capabilities.
Learn more about GitOps: https://about.gitlab.com/topics/gitops/
A
Now,
one
thing
to
point
out
here
is
that
gitlab
is
you
know,
tool
agnostic?
It
doesn't
have
to
be
ansible,
but
that's
a
pretty
popular
language
that
people
are
using
for
infrastructure
as
code,
so
I
decided
to
create
a
demo
around
that
I've
also
got
a
terraform
demo,
but
we'll
save
that
for
another
time.
So
if
I
just
look
down
through
the
project
here,
I
can
see
a
number
of
different
tasks
and
things
that
that
ansible
put
together
different
different
workshops
and
exercises,
and
things
like
that.
A
That's
all
part
of
the
repo
here
that
I
got
but
I'm
going
to
show
you
one
kind
of
very
specific
thing,
which
is
very
simple:
we're
using
the
ansible
networking
class
and
going
to
the
workshop
that
shows
specifically
they're
there
to
router
demo
I've
already
I've
already
set
up
the
environment.
I've
actually
got
the
two.
The
two
router
set
up
and
I've
SSH
tin
to
them
just
for
good
measures
to
make
sure
that
they're
working
but
I've
got
those
sitting
here
and
I
can
see
if
some
active
interfaces
and
some
SNMP
commands
already
set.
A
So
that's
that
squared
away
that's
one
another
router
here
and
and
a
couple
other
SNMP
community
strings
already
preset.
So
what
I'm
going
to
show
you
today
is
using
the
power
of
get
lab
and
the
runners
to
execute
playbooks.
So
I've
got
a
particular
playbook
here.
It's
got
one
file
and,
if
I
open
up
this
playbook,
if
you're
familiar
with
ansible
very
simple
here,
I
just
call
out
what
my
hosts
are
and
I've
got
four
tasks.
A
First
task
is
just
gathering
iOS
facts:
it
prints
out
a
iOS
version
for
the
routers
that
are
in
the
this
host
file,
prints
out
the
serial
number,
and
then
it
does
some
configuration
as
well.
So
does
the
iOS
uses
the
iOS
config
module
to
send
two
commands?
The
SNMP
set
the
SNMP
string
for
read
only
and
read
write,
so
this
is
what's
existing.
A
What
I'm
going
to
do
is
I'm
going
to
edit
this
and
then
I'm
going
to
execute
it
all
without,
without
installing
anything
on
my
laptop
or
any
dependencies
I'm
going
to
use
this
entirely
run
out
of
get
lab,
comm
hosted
service.
So
first
thing,
I'm
going
to
do
is
I'm
going
to
follow
good,
get
flow
or
get
lab
flow
and
I'm
gonna
go
to
my
issue
board
here
and
see
if
I've
got
an
issue,
so
this
would
be
a
typical
workflow.
A
We
would
use
for
ansible
I've
noticed
I've
got
an
open
issue
here
to
change
my
SNMP
strings
on
the
router.
I.
Can
click
into
this
to
take
a
look
at
it?
I
can
drag
it
over
to
the
to-do
column
to
add
a
label
or
I
can
drag
it
over
again
change
the
label,
to
maybe
the
doing
column
here
tag
here,
so
I'm
going
to
click
on
that
I'm,
going
to
open
up
this
issue
and
say
that
okay,
the
issue
title
here
is
change
SNMP
strings
on
router.
A
They
need
to
wrote
the
SNMP
strings
every
month
per
the
security
policy.
Well,
that's
great!
Okay!
Well,
what
is
our
policy
well
part
of
the
issue
template
here
conveniently
links
the
security
policy
and
a
code
sample
for
me
so
I'm,
let's
want
to
click
on
the
security
policy
here.
It's
gonna
drop
me
into
the
wiki
section
of
my
project,
so
this
project
is
ansible
demo
project.
It's
got
a
dedicated
wiki
that
I'm
using
to
lay
out
what
our
security
policies
are.
A
A
I'm
going
to
see
okay
well,
I've
got
a
code
sample
here,
so
I'm
gonna
click
on
that
it's
gonna
jump
me
into
the
snippets
section.
This
is
a
space
where
I
can
add
configuration
that
will
help
me
understand
what
I
need
to
do
for
this
particular
task,
so
example,
code
I
can
see.
I've
got
this.
This
SNMP
iOS
config,
which
we
looked
at
already
and
I've
got
public
and
private
here.
So
this
is
just
a
nice
little
example.
I
can
copy
this
to
my
clipboard
or
or
reference
it
through
a
URL
or
download
it.
A
So,
let's
go
back
to
our
issue
here.
I'm
gonna
go
ahead
and
take
ownership
of
this
issue.
Here.
Click
on
that
so
now,
I'm
assigned
this
issue.
It's
in
the
doing
column.
So
now
I've
just
made
work
visible.
Everybody
knows
that
I'm
working
on
it
on
this
particular
issue.
I
could
make
a
comment
here.
If
I
needed
additional
information,
I
can
call
out
co-workers
or
groups
by
just
tagging
them
simply
in
this
issue,
but
the
next
thing
I'm
going
to
do
now
that
I've
claimed
the
issue.
A
I'm
gonna
create
a
merge
request,
so
a
merge
request
or
github
sometimes
calls
it
a
pull
request.
This
is
the
this
is
the
fix,
so
I'm,
just
gonna
click
on
that
quickly,
I'm
gonna
see
it
automatically,
creates
my
merge
request.
It
puts
a
work-in-progress
flag
on
it,
so
everybody
knows
that
I'm
working
on
this-
and
it's
not
quite
done
yet
so
we've
got
change
SNMP
strings
on
the
router.
A
It's
created
a
separate
branch
for
me
to
work
in
outside
a
master
and
preset
at
the
merge
to
say:
ok,
my
changes
are
gonna
merge
back
into
master,
so
this
is
good.
Now,
I
just
need
to
make
these
changes
now.
I
could
run
this
locally
by
doing
a
git
fetch
and
checking
out
the
branch
and
downloading
the
files
and
making
the
changes
and
reuploading,
but
I'm
actually
going
to
just
take
a
shortcut
here
since
I
know
it's
a
quick
change.
I
still
want
to
pop
up.
A
Follow
all
the
good
flow
but
I'm
just
going
to
use
the
web
IDE
here
the
built-in
editor.
So
when
I
do
that,
it
opens
up
kind
of
a
pretty
rich
feature
set
editor
here.
That
allows
me
to
stage
and
commit
my
code.
So
I'm
gonna
go
into
the
CI
CD
demo,
section
I'm
going
to
go
to
that
ansible
playbook
that
I
saw
and
I
know
that
I
need
to
edit
the
configuration
MP
so
I'm
going
to
set
this
to
new
SNMP.
A
Demo,
1
and
I'm
going
to
set
my
read/write
to
something
different
for
my
security
policy,
so
I'm
gonna
do
make
this
the
fun
SNMP
our
W
string.
Okay,
so
now
I've
got
a
new
string
here.
I'm
gonna
commit
this
commit
this
change.
It's
gonna
show
me
the
deltas
that
I've
made
in
my
playbook
so
now.
I
know
that
this
is
what's
changed,
obviously
get
tracks
all
my
changes
and
on
a
line
level,
so
I'm
going
to
add
a
commit
message
here.
A
Update
SNMP
play
book
with
new
values
want
to
commit
that
to
my
working
branch
here
and
stage
in
commit
and
go
back
to
my
code
here
and
I.
Go
back
to
my
merge
request
that
I
was
working
on.
Take
a
look
at
it
here
and
some
magic
is
already
happening
here.
So
now,
I've
got
this
resolved
change.
Snmp
I
can
scroll
down
here.
I
can
see
that
I
can
make
any
additional
comments.
A
I
can
see
the
commits
that
I
made
I
can
see
the
changes
that
are
made
across
multiple
commits,
so
I
know
what's
going
on,
but
the
magic
here
is
in
this
pipeline
and
this
pipeline
means
starting
to
run
and
actually
execute
that
ansible
code
on
my
behalf.
So
if
I
click
into
this
I
can
start
to
see
what's
going
on
so
the
first
thing
it's
doing
is
going
through
kind
of
a
setup
phase
or
a
task
to
provision
those
those
specific
router
instances-
and
this
is
a
much
bigger
playbook.
A
That's
part
of
the
the
overall
infrastructure
here,
but
what
this
is
really
doing
is
just
setting
up
setting
up
my
environment
for
execution,
and/or
testing,
while
this
is
running
I'm,
going
to
look
at
the
file
that
actually
generated
this.
So
let
me
jump
back
into
my
repository
here.
So
one
of
the
extremely
powerful
things
about
git
lab
is
that
everything
is
done
in
a
in
a
single
yamo
file.
A
At
least
the
CI
portion
is-
and
so
I
can
see
here-
that
all
the
magic
here
that's
going
on
is
done
in
48
lines
of
yamo
text
code.
So
something
very
simple
easy
to
read
easy
to
understand.
So
it
starts
with
a
base.
Image
and
I've
just
picked
a
base
image
off
of
docker
hub.
That's
got
it's
got
an
table.
Pre-Installed
with
you
know
on
and
boom.
So
now
I
know
that
I've
got
all
my
prereqs
pre-installed
here.
A
Just
using
this
base
image,
I
don't
have
to
do
anything
more
I've
defined
three
stages
which
we
sort
of
saw
in
the
pipeline
quickly.
But
let's
go
through
what
those
look
like,
so
I've
got
a
deploy
stage,
a
demo
stage
and
a
destroy
stage
so
deploy
is
setting
up
the
environment
demo
is
that
running
just
that
single
CI
file
and
then
destroy
is
to
actually
take
this
environment
down
and
when
I'm
done
so
I
don't
incur
any
more
cloud
costs.
A
So,
if
I
look
at
what
the
setup
does
the
setup
just
does
its
part
of
the
stage
here
I
can
see,
it
runs
for
commands,
runs
ansible
version
just
so.
I
have
that
in
my
log
file,
install
some
prerequisites
and
then
execute
the
provision
lab
PMO
file,
which
tells
it
which,
which
region
to
go
into
and
how
many
instances
that
I
want
of
it
the
run
script,
which
is
in
the
demo
stage.
A
This
relies
on
the
setup,
but
then
does
you
know
four
of
its
own
commands
runs
ansible
version
again,
installs
those
those
dependencies
that
I
need
and
then
executes
is
a
different
playbook,
which
is
actually
the
one
that
we
edited.
So
we
edited
the
CI
mo
file
here,
so
it
executes
just
that
single
file
and
then
I've
got
a
final
stage
here
called
destroy
which
is
going
to
tear
down
the
lab
using
ansible
and
I've
got
that
set
as
a
manual
action.
A
We'll
see
that
in
a
second
they
jump
back
over
to
the
merge
request
here
or
excuse
me,
the
the
pipeline
and
we'll
see
that
my
pipeline
has
passed.
That's
great
and
I've
got
my
AWS
setup.
That's
done
and
I've
got
my
run
script
stage
here.
So
if
I
scroll
back
up
to
the
top
I
can
see
that
the
runner
here,
which
is
the
execution
engine
of
get
lab,
started
with
a
base
image
of
ansible
started
up
that
that
container
downloaded
the
code
that
I
changed,
took
all
those
changes
and
starts
to
execute
those
for
command.
A
So
it
runs
in
ansible
version
installs
the
dependencies
execute
my
playbook
and
I
can
see
the
output
from
the
playbook
here.
So
the
first
task
was
gather
facts.
The
second
was
to
print
the
version.
The
third
was
to
print
the
serial
number
and
the
fourth
was
to
change
the
SNMP
strings
and
I
get
the
output
from
ansible
here,
etc.
A
A
A
A
And
now
it'll
kick
off
another
pipeline
here
to
re-execute
those
those
changes
in
master
can
limit
that
if
I
want-
and
once
that's
done
this
will-
this
is
now
in
a
merged
State.
So
my
merge
request
is
closed
and
my
issue
is
now
closed
it.
So
it
automatically
closed
my
issue
and
my
merge
request
and
I'm
done.
A
Hope
this
was
helpful,
there's
a
lot
of
other
things
in
get
lab
around
managing
projects
and
issues
and
using
Kanban
boards
and
a
lot
of
great
workflow
stuff.
But
here's
a
small
feature
that
I
hope
you
enjoyed
able
to
give
you
a
sense
of
what
you
can
do
with
with
git
lab
and
executing
your
infrastructure
as
code
or
net
DevOps
goals.