#cloud-config
disable_root: 0
ssh_pwauth: True
chpasswd: { expire: False }

users:
  - name: jenkins
    lock-passwd: false
    inactive: false
    system: false
    ssh-authorized-keys:
        - ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA2lEVMvqBVd8DzYyTuQpIHqBJBIzM3vh/aoHEHPu1uy5akmz51ty1Xg5w6cWx7EFE48rgvGxTC8CzpADPGqzmiyCHW2n3+OZhm41n2YEBSdxWeOUTN7+7VMs51R4Awo9E2v6m0c4uppgkLm5yONSBBlJ0/1f5ixyKT8GLIilhc+DQo1WgMnP6LorwLGq2TdowncZUr3+2ZAl8Y2mrjwRWnUvM+g3Njnp8HHfCYsJwTGW8jkMlu4kN2hsRlnDm1UUIylXMJYVNmUczh3euRMV1KLGchcebDl0M1JiOn4+s6RorHSEh2uxsLCNY4bIE7t92kvCoZAPreLsGINAdOPQdrw== unsafe

runcmd:
  - [ "set", "-x" ]
# Break auth and fix it at the very end so ssh-slaves will retry until java is installed. Otherwise, plugin will install java itself which is much slower for some reason
  - [ "chmod", "777", "/home/jenkins/.ssh/" ]
  - [ "chown", "jenkins", "/home/jenkins" ] # Not sure why this is needed - othwrvise owned by root
  - [ "mkdir", "/usr/local/java/" ] # Location searched by ssh-slaves plugin, though not controlled by it
  - [ "curl", "-L", "-o", "/usr/local/java/java.tar.gz", "http://download.oracle.com/otn-pub/java/jdk/8u51-b16/jdk-8u51-linux-x64.tar.gz", "-H", "Cookie: oraclelicense=accept-securebackup-cookie" ]
  - [ "tar", "xf", "/usr/local/java/java.tar.gz", "-C",  "/usr/local/java/", "--strip-components=1" ]
# Fix auth
  - [ "chmod", "700", "/home/jenkins/.ssh/" ]
  - [ "sh", "-c", "echo jenkins:ath | chpasswd" ]
