{"id":16581966,"url":"https://github.com/masasam/ansible-setup-server","last_synced_at":"2025-07-13T17:09:10.286Z","repository":{"id":110989727,"uuid":"73865192","full_name":"masasam/ansible-setup-server","owner":"masasam","description":"Ansible playbook for build a server with one command","archived":false,"fork":false,"pushed_at":"2023-09-25T03:44:10.000Z","size":2723,"stargazers_count":10,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T05:24:09.688Z","etag":null,"topics":["ansible","ansible-playbook","debian","debian-server"],"latest_commit_sha":null,"homepage":"https://solist.work/blog/posts/ansible-handlers/","language":"Jinja","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/masasam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-15T23:39:48.000Z","updated_at":"2023-08-18T01:49:55.000Z","dependencies_parsed_at":"2023-09-25T06:23:36.253Z","dependency_job_id":null,"html_url":"https://github.com/masasam/ansible-setup-server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/masasam/ansible-setup-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masasam%2Fansible-setup-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masasam%2Fansible-setup-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masasam%2Fansible-setup-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masasam%2Fansible-setup-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/masasam","download_url":"https://codeload.github.com/masasam/ansible-setup-server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masasam%2Fansible-setup-server/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265175567,"owners_count":23722661,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","ansible-playbook","debian","debian-server"],"created_at":"2024-10-11T22:30:35.854Z","updated_at":"2025-07-13T17:09:10.266Z","avatar_url":"https://github.com/masasam.png","language":"Jinja","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Preparing the server you want to provision with ansible\n\nTarget OS at the server\n\n- Debian10 buster(Recommended)\n- Centos7(Not doing much maintenance)\n- Archlinux(-_-;)\n\nPerhaps no one will use archlinux at the server(-_-;)\n\n## Synopsis\n\nCreate a server from scratch\n\n\tansible-playbook --ask-vault-pass main.yml\n\nUpdate package inside server\n\n\tansible-playbook --ask-vault-pass update.yml\n\nWrite directory names exist under roles you want to use at main.yml\n\n\t- hosts: server\n\t\tuser: \"{{ username }}\"\n\t\tbecome: yes\n\t\tvars:\n\t   \t- include_tasks: vars/server.yml\n\t   roles:\n\t    - emacs\n\t\t- git\n\t\t- nginx\n\t\t- python\n\t\t- vim\n\t\t- zsh\n\t\t- less\n\t\t- others\n\t\t- selenium\n\nThat is all.\n\n## When creating a Debian server\n\nCreate user to use with ansible as root\n\n\tsudo apt-get install python openssh-server zsh bash-completion sudo\n\tsudo useradd -m -G sudo -s /bin/zsh ansible\n\tsudo su - ansible\n\tssh-keygen -t rsa -b 4096\n\tcd .ssh/\n\tmv id_rsa.pub authorized_keys\n\tchmod 600 authorized_keys\n\tcurl https://github.com/masasam.keys \u003e\u003e ~/.ssh/authorized_keys ← Register public key registered with github\n\nReturn to root\n\n\tsudo systemctl enable ssh\n\tsudo systemctl start ssh\n\nSet host name\n\n\tsudo hostname debian\n\nvisudo\n\n\techo 'ansible ALL=(ALL) ALL' | sudo EDITOR='tee -a' visudo\n\techo '%wheel ALL=(ALL) ALL' | sudo EDITOR='tee -a' visudo\n\techo '%wheel ALL=(ALL) NOPASSWD: ALL' | sudo EDITOR='tee -a' visudo\n\n## Install ansible on your laptop or desktop\n\n\tpip install --user ansible\n\tgit clone https://github.com/masasam/ansible-setup-server.git\n\n## Perform provisioning by ansible\n\n\tansible-playbook --ask-vault-pass main.yml\n\nWrite variables and passwords in group_vars/server.yml\nEncrypt server.yml in advance with the following command\n\n\tansible-vault encrypt group_vars/server.yml\n\nWhat is in group_vars/server.yml (Write a password etc. here)\n\n\thostname: 'yourhost' ← Linux host name\n\tdomain: 'yourdomain' ← Main domain\n\tdomain1: 'www1.yourdomain'\n\tdomain2: 'www2.yourdomain'\n\tdomain3: 'www3.yourdomain'\n\tdomain4: 'www4.yourdomain'\n\tusername: 'ansible' ← User name ansible ssh\n\tmailroot: 'youremailaddress' ← E-mail address to transfer root's mail\n\tmonitalert: 'youremailaddress' ← Destination of alert mail from monit\n\tinfopassword: '1e3396a8ecbc77a4cd81145c2c6b'\n\tmariadbrootpassword: 'mariadbrootpassword' ← The password of the mariadb root user\n\tdbname: 'yourdbbame' ← DB name used in mariadb\n\tdbpassword: 'yourdbpassword' ← That password\n\tdocroot: '/home/html' ← Main document route for nginx\n\tdocroot1: '/home/html1'\n\tdocroot2: '/home/html2'\n\tdocroot3: '/home/html3'\n\tdocroot4: '/home/html4'\n\nInfopassword will be the password for the email address of info@yourdomain\nHow to make infopassword\n\n\tdoveadm pw\n\tEnter new password: yourpassword\n\tRetype new password: yourpassword\n\nWith\n\n\t{CRAM-MD5}913336a8ecba7764cd81245c2c6b\n\nBecause it is\n\n\tinfopassword: '913336a8ecba7764cd81245c2c6b'\n\n#### Update the server only playbook\n\n\tansible-playbook --ask-vault-pass update.yml\n\n## When creating a Debian test container at localhost\n\n\tsudo pacman debootstrap\n\tyaourt -S debian-archive-keyring\n\n\tmkdir debian\n\tsudo debootstrap buster debian http://ftp.jaist.ac.jp/pub/Linux/debian/\n\n\tsudo chroot debian\n\tpasswd root\n\n\tsudo systemd-nspawn -b -D ~/debian\n\nFrom here debian virtual server\n\n\tapt-get install python openssh-server zsh bash-completion sudo\n\n\tuseradd -m -G sudo -s /bin/zsh ansible\n\tsu - ansible\n\tssh-keygen -t rsa -b 4096\n\tcd .ssh/\n\tmv id_rsa.pub authorized_keys\n\tchmod 600 authorized_keys\n\tcurl https://github.com/masasam.keys \u003e\u003e ~/.ssh/authorized_keys ← Register public key registered with github\n\nReturn to root\n\n\tsystemctl enable ssh\n\tsystemctl start ssh\n\nSet host name\n\n\thostname debian\n\nvi /etc/hosts\n\n\t127.0.0.1       localhost debian\n\nSet up a user (group) that sudo can use\n\n\tupdate-alternatives --config editor\n\nvisudo\n\n\techo 'ansible ALL=(ALL) ALL' | sudo EDITOR='tee -a' visudo\n\techo '%wheel ALL=(ALL) ALL' | sudo EDITOR='tee -a' visudo\n\techo '%wheel ALL=(ALL) NOPASSWD: ALL' | sudo EDITOR='tee -a' visudo\n\nSet the following in .ssh/config on your laptop or desktop\n\n\tHost debiantest\n\t\t\t\t\t\tHostName localhost\n\t\t\t\t\t\tUser ansible\n\nWrite at main.yml\n\n\t- hosts: debiantest\n\nRun playbook\n\n\tansible-playbook --ask-vault-pass main.yml\n\n## When creating a centos test container at localhost\n\n\tyaourt yum\n\tmkdir centos\n\n\tsudo vim /etc/yum/repos.d/centos.repo\n\t[centos]\n\tname=centos\n\tbaseurl=http://ftp.jaist.ac.jp/pub/Linux/CentOS/7/os/x86_64/\n\tenabled=1\n\n\tsudo yum -y --releasever=7 --installroot=~/centos groupinstall \"Base\"\n\n\tsudo chroot centos\n\tpasswd root\n\n\tsudo systemd-nspawn -b -D ~/centos\n\nCreate user to use with ansible as root\nUser name should be ansible\n\n\tyum install python openssh-server zsh bash-completion sudo\n\tuseradd -m -G wheel -s /bin/zsh ansible\n\tsu - ansible\n\tssh-keygen -t rsa -b 4096\n\tcd .ssh/\n\tmv id_rsa.pub authorized_keys\n\tchmod 600 authorized_keys\n\tcurl https://github.com/masasam.keys \u003e\u003e ~/.ssh/authorized_keys ← Register public key registered with github\n\nReturn to root\n\n\tsystemctl enable sshd\n\tsystemctl start sshd\n\nSet host name\n\n\thostname centos\n\nvi /etc/hosts\n\n\t127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 centos\n\nvi /etc/pam.d/su\n\n\t# Remove comment out\n\tauth required pam_wheel.so use_uid\n\nSet up a user (group) that sudo can use\n\nvisudo\n\n\t#Defaults    requiretty(Confirm whether commented out)\n\n\techo 'ansible ALL=(ALL) ALL' | sudo EDITOR='tee -a' visudo\n\techo '%wheel ALL=(ALL) ALL' | sudo EDITOR='tee -a' visudo\n\techo '%wheel ALL=(ALL) NOPASSWD: ALL' | sudo EDITOR='tee -a' visudo\n\nSet the following in .ssh/config on your laptop or desktop\n\n\tHost centostest\n\t\t\t\t\t\tHostName localhost\n\t\t\t\t\t\tUser ansible\n\nWrite at main.yml\n\n\t- hosts: centostest\n\nRun playbook\n\n\tansible-playbook --ask-vault-pass main.yml\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasasam%2Fansible-setup-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmasasam%2Fansible-setup-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasasam%2Fansible-setup-server/lists"}