Automate your Docker deployments with Ansible

Ansible Docker Deployments for your Servers made easily! In this video, I'll show you how I've used Ansible to automate my web server deployments. We're deploying Portainer, Watchtower, and a WordPress Blog. #Ansible #Docker #Watchtower
DOCS: github.com/christianlempa/vid...
Ansible Tutorial: • Simple automation for ...
Get started with Docker: • The Difference between...
Portainer Tutorial: • Portainer Install Ubun...
Watchtower Tutorial: • How To Update Docker C...
Get started with DevOps: • Video
Follow me:
TWITTER: / christianlempa
INSTAGRAM: / christianlempa
DISCORD: / discord
GITHUB: github.com/christianlempa
PATREON: / christianlempa
MY EQUIPMENT: kit.co/christianlempa
Timestamps:
00:00 - Introduction
01:05 - What we do in this tutorial
01:56 - Pre-Requisites
04:47 - Set up our Ansible Environment
08:23 - Install Docker on our remote Server
11:44 - Deploy Portainer
15:19 - Install Watchtower
16:35 - Deploy WordPress
----
All links with "*" are affiliate links.

Пікірлер: 76

  • @christianlempa
    @christianlempa3 жыл бұрын

    Note, if you haven't installed ansible before via pip and you're doing a fresh installation via pip, make sure you add this line to your .bashrc or .zshrc file! export PATH=$PATH:$HOME/.local/bin

  • @mmrk_

    @mmrk_

    3 жыл бұрын

    Hello! Was wondering what does `export PATH=$PATH:$HOME/.local/bin` do for us in this case? Is there a particular spot in the .bashrc config that we should add this line?

  • @mmrk_

    @mmrk_

    3 жыл бұрын

    After some research. "export PATH=$PATH:$HOME/.local/bin" will add Ansible to your Path and will let you use the "ansible" command. You can add this line to the top of the .bashrc file. You have to use the following command after adding it to your .bashrc file in order for it to work. ". .bashrc" or `source .bashrc` Hope this helps others that ran into the same roadblock.

  • @christianlempa

    @christianlempa

    3 жыл бұрын

    @@mmrk_ Thanks for sharing! :)

  • @devvar912

    @devvar912

    Жыл бұрын

    Thanks for your work! But can you explain why it says Unable to connect, when i installed portainer and trying to check connection? Not on vm, neither on host

  • @kjakobsen

    @kjakobsen

    Жыл бұрын

    I'm installing a control node on WSL Ubuntu 22.04, after adding the path it works perfect. :)

  • @unit7psyclone35
    @unit7psyclone353 жыл бұрын

    Excellent Tutorial for Ansible and Docker. Thanks Again Christian.

  • @christianlempa

    @christianlempa

    3 жыл бұрын

    Thank you so much! :)

  • @user-de7vk7gm7b
    @user-de7vk7gm7b2 жыл бұрын

    Благодарю, очень полезное видео!! I grateful to you for this a very useful video!

  • @rob280
    @rob2805 ай бұрын

    Enjoyed your video, was not able to find your docker-install.yaml it your boiler plate folders but did find enough to get docker installed then was able to read your video to get the python package manager and python sdk installed. Overall this video was well done and had a lot of information in it. Thank you.

  • @annahri
    @annahri2 жыл бұрын

    So much interesting topics on your channel. Subscribed!

  • @christianlempa

    @christianlempa

    2 жыл бұрын

    Thanks mate!

  • @Ultimaus
    @Ultimaus8 ай бұрын

    So I'm just diving into what I need to setup a home lab. Honestly the technical stuff is a treat. Drilling holes for and mapping the cables and drywall is the unwanted brain challenge. I am just getting my feet wet into deploying virtual machines using, home assistant, Linux cli, docker and... well basically everything your channel is about. But my skills are currently just trying to swim through Linux and docker and docker networking. I was looking through some ansible content online and as we tech guys are... we understand why automation is powerful. We understand the power of macro commands and scripted deployment. But as selfish creatures with undefined capacity I still didn't understand why ansible? As these questions are always user defined we just need someone to show how they use it and why. I don't know what it is exactly in your video that made me connect the dots and shout ah hah! But I want you to know it happened and I want to thank you for your time and effort.

  • @TuxTechLabs
    @TuxTechLabs5 ай бұрын

    Cool things shared by Christian as always.

  • @christianlempa

    @christianlempa

    5 ай бұрын

    Thanks :)

  • @Phillisteum
    @Phillisteum2 жыл бұрын

    Great video! Docker stack definition in an Ansible playbook?! Wow! So much potential to automate deployments and update a running stack.

  • @christianlempa

    @christianlempa

    2 жыл бұрын

    Thank you so much! :) That's indeed pretty useful!

  • @dedpossum66
    @dedpossum662 жыл бұрын

    Excellent video! I appreciate it.

  • @christianlempa

    @christianlempa

    2 жыл бұрын

    Glad you enjoyed it!

  • @Mohan-nf6cu
    @Mohan-nf6cu2 жыл бұрын

    Thanks a lot. Excellent explanation:) :)

  • @christianlempa

    @christianlempa

    2 жыл бұрын

    Glad you liked it

  • @jamesT008
    @jamesT0082 жыл бұрын

    Great....very informative

  • @christianlempa

    @christianlempa

    2 жыл бұрын

    Thank!

  • @mohdasgharnaqvi5955
    @mohdasgharnaqvi59552 жыл бұрын

    U r really helpful thanks

  • @christianlempa

    @christianlempa

    2 жыл бұрын

    Great! Thanks

  • @andyruiz3174
    @andyruiz31743 жыл бұрын

    Sehr gutes Video... hast die ein Abo verdient

  • @christianlempa

    @christianlempa

    3 жыл бұрын

    Danke 😁

  • @andreaghensi7579
    @andreaghensi75792 жыл бұрын

    great tutorial as always! I ran into an error similar of what you talk about at 14:30, but mine occurred because I was adding my ansible user to the docker group just before using the docker_container module (I'm trying a zero-to-homelab playbook here)... all I had to do to solve this was to add a reset_connection task to ensure the ansible user had the right permissions.

  • @christianlempa

    @christianlempa

    2 жыл бұрын

    Thanks! Sounds interesting, I was able to fix it all by installing the right packages.

  • @jeremyr7958
    @jeremyr7958 Жыл бұрын

    Question: If you are not using vagrant, which many don't, what do you enter in the config file instead of the vagrant private key file path?

  • @SMAW04
    @SMAW043 жыл бұрын

    Nice video, got some ideas from it! thank you. One question, which theme are you using in you're WSL ZSH it looks nice!

  • @christianlempa

    @christianlempa

    3 жыл бұрын

    Hey, thanks! :) I just updated my dotfiles github repo, there you'll find the settings and the color scheme for the Windows Terminal: github.com/xcad2k/dotfiles

  • @haralc
    @haralc Жыл бұрын

    I'm surprised even after a year later after this video that the "installing" documentation don't give an option to get Ansible as a container image, so people don't really have to care what python version is installed or whether it's even installed.

  • @chrissaji6988
    @chrissaji69883 жыл бұрын

    Thanks for this tutorial. Could you please create a tutorial to install collabora on nextcloud (installed on docker)?

  • @christianlempa

    @christianlempa

    3 жыл бұрын

    Thanks! Well that would need to wait a long time, until I do that, unfortunately :/

  • @fauzifirdaus8200
    @fauzifirdaus82003 жыл бұрын

    Can u give us tutorial how to connect another server to main portainer and how best practice use watchtower if we want to manage docker in few different server?

  • @christianlempa

    @christianlempa

    3 жыл бұрын

    I've done a video on Watchtower, that might help you: kzread.info/dash/bejne/Z6CEwdKdmsa8fdI.html And also on Portainer Remote Access: kzread.info/dash/bejne/nX940bKomNPPfs4.html Hope that is what you're searching for 😀

  • @yolo-cars
    @yolo-cars Жыл бұрын

    Thank you for this video. I'm following this video and I got a quick question: in ansible.cfg file you specidied remote_user = vagrant. I'm not using vagrant, so I wonder if remote_user should be a regular user which you create when installing Linux or if it should be a root user? Thanks!

  • @christianlempa

    @christianlempa

    Жыл бұрын

    Yep it's the name of a regular Linux user on the remote system

  • @psicodelico6
    @psicodelico63 жыл бұрын

    Excelent tutorial!.. great.. if you migrate cointaner how to get data and then copy en new location docker?

  • @christianlempa

    @christianlempa

    3 жыл бұрын

    Thanks! Glad that you asked because I'm currently preparing a new video about migrating non-docker to docker containers. I think it would be great to integrate migration of docker volumes as well!

  • @psicodelico6

    @psicodelico6

    3 жыл бұрын

    @@christianlempa yes! its would be great.

  • @ronaldagorsah7954
    @ronaldagorsah7954Ай бұрын

    Thanks for the video but the boilerplate is gone and now i misss the boilerplate to install docker

  • @khurrumbaloch1951
    @khurrumbaloch195110 ай бұрын

    Hi Christian, when using this playbook it fails at "No package matching 'docker-ce' is available". How would I circumvent this issue? Thanks in advance!

  • @belaircomputerguyllc4001
    @belaircomputerguyllc40013 жыл бұрын

    Do you get into VM's at all? Which hypervisor do you prefer?

  • @christianlempa

    @christianlempa

    3 жыл бұрын

    I'm currently testing proxmox. Seems pretty good so far

  • @christianlempa

    @christianlempa

    3 жыл бұрын

    I'm currently testing proxmox. Seems pretty good so far

  • @deanxaka
    @deanxaka2 жыл бұрын

    What are you using for yaml in vscode to lool like that

  • @nikhilverma1552
    @nikhilverma15522 жыл бұрын

    Hi, can u also show me how to down docker-compose from remote host

  • @christianlempa

    @christianlempa

    2 жыл бұрын

    Not sure what you mean, remote hosts can be managed with Portainer like local hosts, so also docker-compose stacks.

  • @kjakobsen
    @kjakobsen Жыл бұрын

    The YAML syntax requirements gives me a headache. I oftens find myself, staring at what i typed in, and can't spot what i seemed to have mistyped. How do we overcome this?

  • @Angelas20
    @Angelas202 жыл бұрын

    What shell prompt do you use for nice upper blue part?

  • @christianlempa

    @christianlempa

    2 жыл бұрын

    I've done a video about my setup, here you'll find it :) kzread.info/dash/bejne/oXpqya6ymLSqlNo.html

  • @HoaPham-yb1op
    @HoaPham-yb1op Жыл бұрын

    I follow exactly the steps in your video but I'm getting this error: msg": "Failed to import the required Python library (requests) on vm-test-rh1's Python /usr/bin/python3.9. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter" Can you guess why?

  • @ebiscaia
    @ebiscaia11 ай бұрын

    Wouldn't it be the case of installing Ansible in a vitual environment?

  • @Adityakumar-ly6iy
    @Adityakumar-ly6iy3 жыл бұрын

    I am confused as why we have to write a playbook to install wordpress instead we can write a docker-compose file with all required configuration and run the file using ansible on the host.

  • @christianlempa

    @christianlempa

    2 жыл бұрын

    Works both ways, you can of course also use docker-compose if you want

  • @tekknokrat

    @tekknokrat

    2 жыл бұрын

    You can also use ansible playbook that deploys a docker compose file containing ansible variables. That is sometimes neccessary when you have dynamic parameters that can't be injected by environment vars.

  • @frenchkaonashi5495
    @frenchkaonashi5495 Жыл бұрын

    My comment is so late, but i want to thank you and ask this: What is the tool ur using to get linux command suggestions?

  • @christianlempa

    @christianlempa

    Жыл бұрын

    I think I was using autosuggestions as a plug-in for zsh at this time

  • @KrachaborasJB
    @KrachaborasJB2 жыл бұрын

    Which vscode extension sets different colors on columns ?

  • @christianlempa

    @christianlempa

    2 жыл бұрын

    That's indent rainbow.

  • @Knightfall23
    @Knightfall232 жыл бұрын

    What is that webpage home setup you have at 15:09?

  • @twinssword

    @twinssword

    2 жыл бұрын

    Brave browser default page

  • @lonewolfcoding5208
    @lonewolfcoding5208 Жыл бұрын

    i like it because its agentless

  • @neoplasma1
    @neoplasma12 жыл бұрын

    Doesn’t Portainer take away the learning process of actually using Docker?

  • @christianlempa

    @christianlempa

    2 жыл бұрын

    To some extend, yes. But people still would need at least some fundamental knowledge of Docker, and I always prefer people to teach the fundamentals first before using tools to simplify the daily workflow.

  • @techwithbube
    @techwithbube2 жыл бұрын

    How can i print a mesage when I vagrant ssh into a VM ?

  • @johanelmander3787
    @johanelmander37878 күн бұрын

    This is not automating docker deployment, in remote server you just installed docker and pulled wordpress image from dockerhub. This is not deployment

  • @jackbolder5734
    @jackbolder5734 Жыл бұрын

    Is it just me, or is the video quality terrible even at 1080p? Barely can read that yaml (Europe).

  • @christianlempa

    @christianlempa

    Жыл бұрын

    Idk, maybe that’s an issue with the compression

  • @Glatze603
    @Glatze6033 жыл бұрын

    Hi Christian! Thanks for this video, but yout description doesn't work an ubuntu 20.04. I removed older ansible version, but bevor install new one, I had to install python3-pip - maybe you are a little bit "betriebsblind" because you had it already installed? After installation of ansible (python3 -m pip install ansible) I wasn't able to use it, because system looks at "/usr/bin/ansible". Symlink new one from ~/.local/bin/ to /usr/bin first seems to work (ansible --version > 2.10.8), but next command "ansible-galaxy collection install community.docker" crashes with "Der Befehl 'ansible-galaxy' wurde nicht gefunden kann aber installiert werden mit: sudo apt install ansible"... Whats wrong?!? Maybe you could add some missing details, so that we could profit from this great content? Thanks a lot and please continue in making such nice videos. I would like another video hot to config and deploy a vm with ansible (I already tried, but didn't got it to work).

  • @Glatze603

    @Glatze603

    3 жыл бұрын

    Ok, I had to symlink all files from ~/.local/bin to /usr/bin...

  • @christianlempa

    @christianlempa

    3 жыл бұрын

    @@Glatze603 Danke für's bescheid sagen! Ja das stimmt, ich hatte den symlink erstellen müssen, bzw. du kannst mit "export PATH=$PATH:$HOME/.local/bin" in der .zshrc oder .bashrc datei das einstellen. Ich füge das gleich mal ins tutorial hinzu!