# Vagrant - CentOS, Debian i Ubuntu

**URL:** <https://forum.manjaro.pl/t/vagrant-centos-debian-i-ubuntu/241>\
**Category:** Skrypty, porady i tutoriale\
**Created:** [23 Luty 2019 12:15 UTC](https://forum.manjaro.pl/t/vagrant-centos-debian-i-ubuntu/241 "2019-02-23T12:15:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Autor:** ![napcok](https://forum.manjaro.pl/user_avatar/forum.manjaro.pl/napcok/32/4088_2.png) [@napcok](https://forum.manjaro.pl/u/napcok)\
**Data wpisu:** [23 Luty 2019 12:15 UTC](https://forum.manjaro.pl/t/vagrant-centos-debian-i-ubuntu/241/1 "2019-02-23T12:15:29Z")

</div>

Wrzucam plik Vagrantfile do odpalenia dystrybucji najczęściej spotykanych na serwerach (CentOS 8, Debian 10, Ubuntu 20.04)  
Może komuś się przyda do nauki czy zabawy.

```auto
servers=[
  {
    :hostname => "centos",
    :ip => "192.168.100.10",
    :box => "centos/8",
    :ram => 1024,
    :cpu => 1
  },
  {
    :hostname => "debian",
    :ip => "192.168.100.11",
    :box => "debian/buster64",
    :ram => 1024,
    :cpu => 1
  },
  {
    :hostname => "ubuntu",
    :ip => "192.168.100.12",
    :box => "ubuntu/focal64",
    :ram => 1024,
    :cpu => 1
  }
]

Vagrant.configure(2) do |config|
    servers.each do |machine|
        config.vm.define machine[:hostname] do |node|
            node.vm.box = machine[:box]
            node.vm.hostname = machine[:hostname]
            node.vm.network "private_network", ip: machine[:ip]
            node.vm.provider "virtualbox" do |vb|
                vb.customize ["modifyvm", :id, "--memory", machine[:ram]]
            end
        end
    end
end

```

---

<div class="post-metadata">

**Autor:** ![napcok](https://forum.manjaro.pl/user_avatar/forum.manjaro.pl/napcok/32/4088_2.png) [@napcok](https://forum.manjaro.pl/u/napcok)\
**Data wpisu:** [31 Październik 2019 14:07 UTC](https://forum.manjaro.pl/t/vagrant-centos-debian-i-ubuntu/241/2 "2019-10-31T14:07:02Z")

</div>

Jakby ktoś miał ochotę na naukę o Linuksie na serwerze to wrzucam link do uaktualnionego artykułu o Vagrancie …

[https://serwer-vps.pl/vagrant-doskonale-narzedzie-do-nauki-i-testowania/](https://serwer-vps.pl/vagrant-doskonale-narzedzie-do-nauki-i-testowania/)

---

<div class="post-metadata">

**Autor:** ![UltherEgo](https://forum.manjaro.pl/user_avatar/forum.manjaro.pl/ultherego/32/3169_2.png) [@UltherEgo](https://forum.manjaro.pl/u/UltherEgo)\
**Data wpisu:** [1 Maj 2020 13:40 UTC](https://forum.manjaro.pl/t/vagrant-centos-debian-i-ubuntu/241/3 "2020-05-01T13:40:40Z")

</div>

Warto do takiej konfiguracji, którą podał @napcok dodać sobie wyzwalacz skryptu. Dopisujemy linijkę `config.vm.provision :shell, inline: $config`, a na końcu całego pliku np.

```auto
$config = <<-SHELL
  USER="xxxx" # Your user name
  PASS="xxxx" # Your password for user
  
  # Package install
  apt-get install vim python-apt -y
  
  # SHH Config
  sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
  systemctl restart sshd.service

  # Add User
  useradd -m -s /bin/bash -U $USER -u 666 --groups sudo
  cp -pr /home/vagrant/.ssh /home/$USER/
  chown -R $USER.$USER /home/$USER/
  echo "$USER:$PASS" | chpasswd

SHELL

```

Ułatwia i przyspiesza pracę, zwłaszcza gdy podstawowe rzeczy jak vim i ssh powinny być już skonfigurowane zaraz po starcie maszynki.
