►
Description
Shawn Hurley (Red Hat) talk recorded at August 17th 2018 OpenShift Commons Operator Framework SIG meeting
The Ansible Operator is:
- using the new Ansible k8s modules to manage kubernetes resources, allowing for easy templating
- using Ansible Runner to allow for structured output
- using helpers that wil help a user set metadata of a resource in kubernetes i.e. the owner reference
A
B
Hi
everybody
I'm
Shawn
Hurley
I
work
at
Red
Hat,
with
a
team
of
guys
working
on
the
ansible
operator,
which
will
be
eventually
part
of
the
operator
SDK
so
really
quickly.
We
just
kind
of
want
to
talk
about
why
we
chose
ansible
as
a
for
the
operator.
One
of
the
really
powerful
things
about
ansible
is
that
we're
using
the
new
kubernetes
modules
that
will
manage
communities
resources.
It
makes
it
really
easy
to
template
communities,
resources
just
using
ansible,
so
you
can
do
all
the
ansible
things
that
you
can
do
and
also
manage
various
resources.
B
How
you
have
come
to
expect
with
other
tools.
We
also
are
able
to
use
ansible
runner,
which
allows
us
to
run
a
playbook
or
a
standalone
role,
means
that
we
can
reuse
roles
and
just
run
them
right
from
ansible
runner
as
well
as
a
playbook.
It
also
gives
us
structured
output,
which
will
help
us
help
an
operator
author
manage
their
status
of
their
resource,
and
then
we
also
have
some
helpers
that
will
allow
us
to
kind
of
hide
the
details
of
knowing
about
our
references
and
things
and
metadata
of
a
cover
news
resource.
So
I'll.
B
Just
quickly
go
through
the
design
of
what
we
got
started
with
so
at
the
top.
Here
we
have
a
user
going
ahead
and
creating
a
custom
resource
where
they
will
define
their
application
state
and
then
the
ansible
operator
will
be
watching
for
that
resource
yeah.
The
ansible
operator
is
based
on
the
operator
SDK,
and
so
it
has
all
of
the
the
go
watch
logic
based
on
the
operator
SDK,
and
then
it
has
a
config
file
which
Maps
the
group
version
kind
of
that
resource
to
the
ansible
playbook
or
roll
the
ansible
playbook.
B
A
roll
is
then,
whenever
an
event
happens
on
that
custom
resource
and
that
playbook,
a
roll
will
actually
create
the
application
state
in
the
cluster.
So
that
will
create
all
your
resources
that
you
need
and
allows
you
to
manage
your
application
using
ansible
and,
like
I,
said
previously
we're
using
the
new
modules.
B
So
builders
really
help
out.
So
we're
gonna
quickly
talk
about
that
configuration
file
that
I
just
talked
about
we're
a
match:
the
group
version
kind
to
a
playbook
or
a
roll.
This
is
really
the
heart
of
how
this
works.
Is
you
now
define
your
CRD
screen
version
kind
and
you
tell
it
which
playbook
you
wanted
to
do
you
package
that
up
into
the
container
and
then
the
ansible
operator
now
knows
what
to
do
when
the
events
come
in
for
that
resource.
B
So
next
thing
we
can
talk
about
is
how
are
we
going
to
hand
parameters
to
ansible
based
on
the
spec
that
the
user
defines
for
their
resource,
and
so
what
we've
determined
is
that
the
spec
key
values
can
map
well
to
ansible
extra
VARs,
and
these
will
allow
us
to
say
a
user
defines
their
spec,
and
then
we
tell
the
ansible
what
that
what
those
user-defined
parameters
are.
The
ansible
operator
also
will
take
a
first
stab
at
managing
the
status
for
the
operator
author,
as
the
operators
are
supposed
to
own
statuses.
B
We
thought
it
was
important
that
we
do
this
and
because
of
ansible
runner,
we're
able
to
get
structured
output
about
what
is
happening
in
the
ansible
run
and
surface
that
to
the
user,
who
only
wants
to
look
at
their
CR
that
they
created.
So
that's
what
we're
doing
here
so,
as
you
can
see
like
green,
is
the
user
to
find
stuff,
and
then
the
blue
stuff
is
what
the
operator
is
managing.
B
So
you
might
be
asking:
how
do
you
end
up
using
the
ansible
operator?
One
of
the
ways
that
we
we
envision
using
the
ansible
operator
is
using
a
base
image
and
then
you're
only
responsible
for
creating
that
config
file,
creating
a
custom
resource
definition
and
then
writing
the
ansible
code
that
you
need
to
do
the
logic
and
work
that
you
want
it
to
do.
B
B
B
So
sorry
about
that
guys,
so
this
is
the
task.
What
it
will
do
is
like
I
said
it
will
just
turn
out
a
message
that
we
define
from
the
CR,
but
it
also
has
a
default
so
because
a
school
already
has
default.
B
So
what?
And
we
can
also
look
at
this
docker
file
here,
because
that's
the
other
thing
that
matters
we
can
see
that
we're
using
our
base,
we're
going
to
copy
in
the
busybox
role,
we're
gonna
copy
in
the
playbook
and
we'll
also
copy
in
the
ansible
config,
the
config
file
for
the
ansible
operator,
so
we're
gonna
go
ahead
and
just
deploy
this
operator.
I
already
have
okay,
sorry
about
that.
B
B
You
can
see
actually
got
our
first
event.
It
is
taking
so
long.
There
we
go
so
now.
Ansible
is
running.
You
can
actually
see
the
ansible
output
right
now
and
we
have
our
busybox
pod
running.
So
we
can
go
ahead
and
see
what
that
guy
is
doing.
As
you
can
see
us
just
printing
out
hello
world,
let's
say
we
wanted
to
change
that
message.
What
we
could
do
is
just
edit
my
CR.
A
B
You
can
see
it
saying
new
hello
world,
and
so,
if
you
remember,
we
just
took
this
role
and
we're
starting
to
use
it
and
that
role
really
didn't
have
anything
to
do
with.
Let's
say
owner
references.
So
as
an
ansible
operator,
author
who's,
just
writing
ansible.
You
might
not
know
that
you
need
a
set
and
known
a
reference
to
be
able
to
do
garbage
collection
on
the
in
school
operator.
B
B
B
What
we're
thinking
is
that,
because
the
ansible
operator
code
will
be
part
of
the
upper
address
UK,
you
can
actually
use
the
operator
SDK
ansible
operator
code.
The
same
way
you
would
the
operator
SDK
code.
This
means
that
you
can
actually
compose
pieces
of
ansible
that
you
might
want
to
run
from
Lenora
a
go
operator
that
you're
writing
to
give
you
more
flexibility,
so
you
can
do
things
that
you
would
like
to
do.
B
So
that's
one
other
way
that
we're
planning
on
allowing
people
to
use
this.
So
if
you
want
to
learn
more,
this
is
like
a
pre-alpha
application.
We're
still
very
much
in
the
early
stages
and
it
will
be
PR
will
be
submitted
in
about
one
or
two
months
to
the
operator
SDK
to
get
this
fully
baked
in
right.
Now,
it's
in
waterhole
ansible
operator,
there's
a
link
right
there
for
you
guys
to
go
to,
and
most
of
our
team
is
hanging
out
already
in
the
car,
any
slack
in
the
kubernetes
operators
channel.
B
A
C
We
would
say
one
thing
about
the
goal,
for
this
is
really
exciting,
which
is
to
the
technology
skills
that
you
know
an
ocular
off
of
has
and
so
going.
You
know,
a
great
language,
you
know
can
be
a
little
bit
of
Oaks
might
not
have
skills,
or
you
know,
if
you're,
in
a
focus
verse
dead
for
15,
you
shouldn't
have
to
learn
a
programming
language
to
make
an
operator,
and
so
this
is
really
going
to
bridge
those
gaps
where
you
can
start
with
instable.
C
If
you
do
want
to
start
calling
some
custom
go
code,
then
you
can
kind
of
level
up
to
that,
then
maybe
you
know
you'll
fully
transition
to
go,
or
maybe
not
so
that's
really
exciting,
and
so
this
joins
our
helm
operator
kit
and
there
works
much
the
same
way
where
you
just
use
this
base
image
you
not
to
produce
anything.
You
just
add
a
few
files
in
you
know
your
chart
and
you're
good
to
go,
and
so
this
will
operate
much
the
same
way
and
which
is
really
exciting.
C
To
make
this
a
wider
audience
that
can
produce
operators
which
is
really
exciting
and
then
the
other
thing
that
ansible
bring
to
the
table,
which
is
really
really
cool,
is
that
there's
this
plethora
of
ansible
already
written
out
there?
And
so
you
can
connect.
You
know,
orchestrating
external
hardware,
load
balancers,
for
example,
all
the
things
you
can
do
in
the
ansible
ecosystem,
with
an
operator
into
your
kubernetes
cluster
natively,
which
is
super
super
exciting.