Automate your Docker deployments with Ansible

Sdílet
Vložit
  • čas přidán 7. 07. 2024
  • 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.

Komentáře • 77

  • @christianlempa
    @christianlempa  Před 3 lety +12

    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_ Před 3 lety

      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_ Před 3 lety +4

      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  Před 3 lety

      @@mmrk_ Thanks for sharing! :)

    • @devvar912
      @devvar912 Před rokem

      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 Před rokem

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

  • @user-de7vk7gm7b
    @user-de7vk7gm7b Před 2 lety +1

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

  • @unit7psyclone35
    @unit7psyclone35 Před 3 lety +3

    Excellent Tutorial for Ansible and Docker. Thanks Again Christian.

  • @Ultimaus
    @Ultimaus Před 9 měsíci +1

    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
    @TuxTechLabs Před 7 měsíci +1

    Cool things shared by Christian as always.

  • @Phillisteum
    @Phillisteum Před 2 lety +5

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

    • @christianlempa
      @christianlempa  Před 2 lety +1

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

  • @annahri
    @annahri Před 2 lety

    So much interesting topics on your channel. Subscribed!

  • @rob280
    @rob280 Před 7 měsíci

    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.

  • @dedpossum66
    @dedpossum66 Před 2 lety

    Excellent video! I appreciate it.

  • @Mohan-nf6cu
    @Mohan-nf6cu Před 3 lety

    Thanks a lot. Excellent explanation:) :)

  • @jamesT008
    @jamesT008 Před 2 lety

    Great....very informative

  • @mohdasgharnaqvi5955
    @mohdasgharnaqvi5955 Před 2 lety +1

    U r really helpful thanks

  • @jeremyr7958
    @jeremyr7958 Před 2 lety +2

    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?

  • @andreaghensi7579
    @andreaghensi7579 Před 2 lety

    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  Před 2 lety

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

  • @andyruiz3174
    @andyruiz3174 Před 3 lety

    Sehr gutes Video... hast die ein Abo verdient

  • @yolo-cars
    @yolo-cars Před 2 lety

    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  Před 2 lety +1

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

  • @SMAW04
    @SMAW04 Před 3 lety +2

    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  Před 3 lety +1

      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 Před rokem +2

    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.

  • @khurrumbaloch1951
    @khurrumbaloch1951 Před rokem

    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!

  • @chrissaji6988
    @chrissaji6988 Před 3 lety +1

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

    • @christianlempa
      @christianlempa  Před 3 lety +2

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

  • @Angelas20
    @Angelas20 Před 2 lety +1

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

    • @christianlempa
      @christianlempa  Před 2 lety +1

      I've done a video about my setup, here you'll find it :) czcams.com/video/oF6gLyhQDdw/video.html

  • @deanxaka
    @deanxaka Před 2 lety

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

  • @fauzifirdaus8200
    @fauzifirdaus8200 Před 3 lety +1

    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  Před 3 lety

      I've done a video on Watchtower, that might help you: czcams.com/video/5lP_pdjcVMo/video.html
      And also on Portainer Remote Access: czcams.com/video/kKDoPohpiNk/video.html
      Hope that is what you're searching for 😀

  • @kjakobsen
    @kjakobsen Před rokem

    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?

  • @HoaPham-yb1op
    @HoaPham-yb1op Před rokem

    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
    @ebiscaia Před rokem

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

  • @belaircomputerguyllc4001
    @belaircomputerguyllc4001 Před 3 lety +1

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

    • @christianlempa
      @christianlempa  Před 3 lety +2

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

    • @christianlempa
      @christianlempa  Před 3 lety +1

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

  • @sudeep_jadhav
    @sudeep_jadhav Před 19 dny

    Docker with Terraform can be done?

  • @nikhilverma1552
    @nikhilverma1552 Před 3 lety

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

    • @christianlempa
      @christianlempa  Před 3 lety

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

  • @KrachaborasJB
    @KrachaborasJB Před 3 lety

    Which vscode extension sets different colors on columns ?

  • @ronaldagorsah7954
    @ronaldagorsah7954 Před 2 měsíci

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

  • @Adityakumar-ly6iy
    @Adityakumar-ly6iy Před 3 lety +1

    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  Před 3 lety +2

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

    • @tekknokrat
      @tekknokrat Před 2 lety

      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.

  • @psicodelico6
    @psicodelico6 Před 3 lety

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

    • @christianlempa
      @christianlempa  Před 3 lety +1

      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 Před 3 lety

      @@christianlempa yes! its would be great.

  • @Knightfall23
    @Knightfall23 Před 2 lety

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

  • @frenchkaonashi5495
    @frenchkaonashi5495 Před rokem

    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  Před rokem +1

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

  • @techwithbube
    @techwithbube Před 2 lety

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

  • @lonewolfcoding5208
    @lonewolfcoding5208 Před rokem

    i like it because its agentless

  • @neoplasma1
    @neoplasma1 Před 2 lety +1

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

    • @christianlempa
      @christianlempa  Před 2 lety

      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.

  • @jackbolder5734
    @jackbolder5734 Před rokem

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

    • @christianlempa
      @christianlempa  Před rokem +1

      Idk, maybe that’s an issue with the compression

  • @johanelmander3787
    @johanelmander3787 Před měsícem

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

  • @Glatze603
    @Glatze603 Před 3 lety

    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 Před 3 lety

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

    • @christianlempa
      @christianlempa  Před 3 lety +1

      @@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!