raise Exception('`{}` did not work as expected.stdout:{} stderr:{}'.format( command, stdout, stderr)) if host.fact.linux_name == 'Ubuntu': code_name = host.fact.linux_distribution['release_meta'].get('DISTRIB_CODENAME') print(host.fact.linux_name, code_name) apt.packages( {'Install packages'}, ['wget'], update=True, ) apt.key( {'Install VirtualBox key'}, 'https://www.virtualbox.org/download/oracle_vbox_2016.asc', ) apt.repo( {'Install VirtualBox repo'}, 'deb https://download.virtualbox.org/virtualbox/debian {} contrib'.format(code_name), ) # install kernel headers # Note: host.fact.os_version is the same as `uname -r` (ex: '4.15.0-72-generic') apt.packages( { 'Install VirtualBox version {} and ' 'kernel headers for {}'.format(virtualbox_version, host.fact.os_version), }, [
def install_caddy(caddy_config: CaddyConfig, state=None, host=None): if caddy_config.plugins: caddy_user = "******" server.user( name="Create system user for Caddy", user=caddy_user, system=True, ensure_home=False, state=state, host=host, ) caddy_install = files.download( name="Download custom build of Caddy", dest="/usr/local/bin/caddy", src=caddy_config.custom_download_url(), mode=DEFAULT_DIRECTORY_MODE, state=state, host=host, ) files.directory( name="Create Caddy configuration directory", path="/etc/caddy/", user=caddy_user, group=caddy_user, present=True, recursive=True, state=state, host=host, ) files.directory( name="Create Caddy configuration directory", path=caddy_config.data_directory, user=caddy_user, group=caddy_user, present=True, recursive=True, state=state, host=host, ) files.template( name="Create SystemD service definition for Caddy", dest="/usr/lib/systemd/system/caddy.service", src=Path(__file__).parent.joinpath("templates/caddy.service.j2"), state=state, host=host, ) else: apt.key( name="Add Caddy repository GPG key", src="https://dl.cloudsmith.io/public/caddy/stable/gpg.key", state=state, host=host, ) apt.repo( name="Set up Caddy APT repository", src="deb https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main", # noqa: E501 present=True, filename="caddy.list", state=state, host=host, ) caddy_install = apt.packages( name="Install Caddy from APT", packages=["caddy"], present=True, latest=True, update=True, state=state, host=host, ) if caddy_config.log_file: files.directory( name="Crate Caddy log directory", path=caddy_config.log_file.parent, user=caddy_user, present=True, state=state, host=host, ) return caddy_install.changed
'ca-certificates', 'curl', 'gnupg-agent', 'software-properties-common', ], update=True, ) docker_key_exists = False stdout = host.fact.command('apt-key list') if 'Docker' in stdout: docker_key_exists = True if not docker_key_exists: apt.key( {'Add the Docker apt gpg key if we need to'}, key='https://download.docker.com/linux/ubuntu/gpg', ) linux_id = host.fact.linux_distribution['release_meta'].get('ID') code_name = host.fact.linux_distribution['release_meta'].get('DISTRIB_CODENAME') print(linux_id, code_name) apt.repo( {'Add the Docker CE apt repo'}, ( 'deb [arch=amd64] https://download.docker.com/linux/' '{} ' '{} stable'.format(linux_id, code_name) ), filename='docker-ce-stable', )
) # NOTE: the bitcoin PPA is no longer supported # apt.ppa( # {'Add the Bitcoin ppa'}, # 'ppa:bitcoin/bitcoin', # ) # # apt.packages( # {'Install Bitcoin'}, # 'bitcoin-qt', # update=True, # ) apt.deb( name='Install Chrome via deb', src= 'https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb', ) apt.key( name='Install VirtualBox key', src='https://www.virtualbox.org/download/oracle_vbox_2016.asc', ) apt.repo( name='Install VirtualBox repo', src='deb https://download.virtualbox.org/virtualbox/debian {} contrib'. format(code_name), )
""" Install Owncloud-Dektop packages. Do not run this file directly. It won't work. Instead run: $ pyinfra @local __file__ """ from pyinfra.operations import apt USE_SUDO_PASSWORD = True apt.key( name="Install Packages / Owncloud / Add GPG Key", src="https://download.owncloud.com/desktop/ownCloud/stable/latest/linux/Ubuntu_20.04/Release.key", sudo=True, ) apt.repo( name="Install Packages / Owncloud / Add Repo", src="deb https://download.owncloud.com/desktop/ownCloud/stable/latest/linux/Ubuntu_20.04/ /", filename="owncloud", sudo=True, ) apt.packages( name="Install Packages / Owncloud / Install Package", packages=["owncloud-client"], sudo=True, update=True, )
Install ROS packages. Do not run this file directly. It won't work. Instead run: $ pyinfra @local __file__ """ from pyinfra.operations import apt USE_SUDO_PASSWORD = True ROS_VERSION="noetic" apt.key( name="Install Packages / ROS / Add GPG Key", keyserver="keyserver.ubuntu.com", keyid="C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654", sudo=True, ) apt.repo( name="Install Packages / ROS / Add Repo", src="deb http://packages.ros.org/ros/ubuntu focal main", filename="owncloud", sudo=True, ) # Note: catkin tools is broken until the OSRF push new packages. # See this issue for a fix: # https://github.com/catkin/catkin_tools/issues/594 # The interim solution is install the git version: # pipx install "git+https://github.com/catkin/catkin_tools.git"
packages=["vim-addon-manager", "vim", "software-properties-common", "wget", "curl"], update=True, ) # NOTE: the bitcoin PPA is no longer supported # apt.ppa( # {'Add the Bitcoin ppa'}, # 'ppa:bitcoin/bitcoin', # ) # # apt.packages( # {'Install Bitcoin'}, # 'bitcoin-qt', # update=True, # ) apt.deb( name="Install Chrome via deb", src="https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb", ) apt.key( name="Install VirtualBox key", src="https://www.virtualbox.org/download/oracle_vbox_2016.asc", ) apt.repo( name="Install VirtualBox repo", src="deb https://download.virtualbox.org/virtualbox/debian {} contrib".format(code_name), )
) apt.packages( name="Ensure Docker CE prerequisites are present", packages=[ "apt-transport-https", "ca-certificates", "curl", "gnupg-agent", "software-properties-common", ], update=True, ) apt.key( name="Add the Docker apt gpg key if we need to", src="https://download.docker.com/linux/ubuntu/gpg", ) lsb_info = host.get_fact(LsbRelease) linux_id = lsb_info["id"].lower() code_name = lsb_info["codename"] apt.repo( name="Add the Docker CE apt repo", src=("deb [arch=amd64] https://download.docker.com/linux/" "{} {} stable".format(linux_id, code_name)), filename="docker-ce-stable", ) apt.packages( name="Ensure Docker CE is installed",
'ca-certificates', 'curl', 'gnupg-agent', 'software-properties-common', ], update=True, ) docker_key_exists = False stdout = host.fact.command('apt-key list') if 'Docker' in stdout: docker_key_exists = True if not docker_key_exists: apt.key( name='Add the Docker apt gpg key if we need to', src='https://download.docker.com/linux/ubuntu/gpg', ) lsb_info = host.fact.lsb_release linux_id = lsb_info['id'].lower() code_name = lsb_info['codename'] apt.repo( name='Add the Docker CE apt repo', src=('deb [arch=amd64] https://download.docker.com/linux/' '{} {} stable'.format(linux_id, code_name)), filename='docker-ce-stable', ) apt.packages( name='Ensure Docker CE is installed',
) apt.packages( name="Install Packages / Compatibility", packages=["ttf-mscorefonts-installer"], latest=True, sudo=True, ) # # Install Sublime Text 3 + Sublime Merge # apt.key( name="Install Packages / Sublime Text 3 / Add GPG Key", src="https://download.sublimetext.com/sublimehq-pub.gpg", sudo=True, ) apt.repo( name="Install Packages / Sublime Text 3 / Add Repo", src="deb https://download.sublimetext.com/ apt/stable/", filename="sublime-text", sudo=True, ) apt.packages( name="Install Packages / Sublime Text 3 / Install Package", packages=["sublime-text", "sublime-merge"], sudo=True, update=True,
from pyinfra import host from pyinfra.operations import apt, server from pyinfra.facts.server import LinuxDistribution linux_distribution = host.get_fact(LinuxDistribution) linux_name = linux_distribution['release_meta']['ID'] linux_codename = linux_distribution['release_meta']['CODENAME'] # Adding tailscale for raspberry pi apt.key( name='Add tailscale key', src='https://pkgs.tailscale.com/stable/{}/{}.gpg'.format( linux_name, linux_codename), ) apt.repo( name='Add tailscale repo', src='deb https://pkgs.tailscale.com/stable/{} {} main'.format( linux_name, linux_codename), filename='tailscale', ) apt.packages( name='Install tailscale', packages=['apt-transport-https', 'tailscale'], update=True, latest=True, ) server.shell(name='Start tailscale', commands=[