[ansible] update irregular-apolcalypse playbook
change
commit 30d0b608827daaa64ce9c7eab81d86a0b27d6d5f
author Alpha Chen <alpha@kejadlen.dev>
date
parent c617fa7b
diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg
index a96c5f7c..37366f16 100644
--- a/ansible/ansible.cfg
+++ b/ansible/ansible.cfg
@@ -3,6 +3,7 @@ inventory = hosts.private
 retry_files_enabled = False
 pipelining = True
 host_key_checking = False
+roles_path = roles
 
 [ssh_connection]
 ssh_args = -o ForwardAgent=yes
diff --git a/ansible/beats-working.yml b/ansible/beats-working.yml
new file mode 100644
index 00000000..4b1c463e
--- /dev/null
+++ b/ansible/beats-working.yml
@@ -0,0 +1,119 @@
+---
+- hosts: beats-working
+  tasks:
+    - name: create user
+      user:
+        name: alpha
+
+
+- hosts: beats-working
+  pre_tasks:
+    - name: update dotfiles repo
+      git:
+        repo: https://github.com/kejadlen/dotfiles.git
+        dest: ~/.dotfiles
+      ignore_errors: yes
+  tasks:
+    - name install dependencies
+      package:
+        name: "{{ item }}"
+        state: present
+      with_items:
+        - mosh
+
+# - hosts: all
+#   tasks:
+#     - name: install dependencies
+#       apt:
+#         name: "{{ item }}"
+#         update_cache: yes
+#       with_items:
+#         - cmake
+#         - direnv
+#         - make
+#         - mosh
+#         - libterm-readkey-perl
+#         - pkg-config
+#         - python3-pip
+#         - software-properties-common
+#         - zsh
+#       become: yes
+
+# - hosts: all
+#   roles:
+#     - dotfiles
+#     - zsh
+
+# - hosts: all
+#   name: create home dirs
+#   tasks:
+#     - file:
+#         path: "{{ item }}"
+#         state: directory
+#       with_items:
+#         - src
+#         - tmp
+
+# - hosts: all
+#   name: install Ansible
+#   tasks:
+#     - apt_repository:
+#         repo: ppa:ansible/ansible
+#       become: yes
+#     - apt:
+#         name: ansible
+#         update_cache: yes
+#       become: yes
+
+# - hosts: all
+#   name: install Ruby
+#   tasks:
+#     - stat: path=/usr/local/bin/chruby-exec
+#       register: chruby
+#     - import_tasks: irregular-apocalypse/chruby.yml
+#       vars:
+#         version: 0.3.9
+#       when: chruby.stat.exists == False
+
+#     - stat: path=/usr/local/bin/ruby-install
+#       register: ruby_install
+#     - import_tasks: irregular-apocalypse/ruby-install.yml
+#       vars:
+#         version: 0.6.1
+#       when: ruby_install.stat.exists == False
+
+#     - stat: path=~/.rubies
+#       register: rubies
+#     - command: ruby-install ruby
+#       when: rubies.stat.exists == False
+
+# - hosts: all
+#   name: install Rust
+#   tasks:
+#     - stat: path=~/.cargo/bin/rustup
+#       register: rustup
+#     - import_tasks: irregular-apocalypse/rustup.yml
+#       when: rustup.stat.exists == False
+
+#     - command: ~/.cargo/bin/rustup toolchain list
+#       register: rustup_toolchains
+#     - name: install rust
+#       command: ~/.cargo/bin/rustup install nightly
+#       when: "'nightly' not in rustup_toolchains.stdout"
+
+#     - name: default to nightly
+#       command: ~/.cargo/bin/rustup default nightly
+
+#     - name: install Rust-based tools
+#       command: ~/.cargo/bin/cargo install {{ item }}
+#       with_items:
+#         - exa
+#         - ripgrep
+
+# - hosts: all
+#   name: install fzf
+#   tasks:
+#     - git:
+#         repo: https://github.com/junegunn/fzf.git
+#         dest: ~/.fzf
+#     - command: ~/.fzf/install
diff --git a/ansible/irregular-apocalypse.yml b/ansible/irregular-apocalypse.yml
deleted file mode 100644
index fd7e9b5f..00000000
--- a/ansible/irregular-apocalypse.yml
+++ /dev/null
@@ -1,105 +0,0 @@
----
-- hosts: all
-  pre_tasks:
-    - name: update dotfiles repo
-      git:
-        repo: https://github.com/kejadlen/dotfiles.git
-        dest: ~/.dotfiles
-      ignore_errors: yes
-
-- hosts: all
-  tasks:
-    - name: install dependencies
-      apt:
-        name: "{{ item }}"
-        update_cache: yes
-      with_items:
-        - cmake
-        - direnv
-        - make
-        - mosh
-        - libterm-readkey-perl
-        - pkg-config
-        - python-pip
-        - software-properties-common
-        - zsh
-      become: yes
-
-- hosts: all
-  roles:
-    - dotfiles
-    - zsh
-
-- hosts: all
-  name: create home dirs
-  tasks:
-    - file:
-        path: "{{ item }}"
-        state: directory
-      with_items:
-        - src
-        - tmp
-
-- hosts: all
-  name: install Ansible
-  tasks:
-    - apt_repository:
-        repo: ppa:ansible/ansible
-      become: yes
-    - apt:
-        name: ansible
-        update_cache: yes
-      become: yes
-
-- hosts: all
-  name: install Ruby
-  tasks:
-    - stat: path=/usr/local/bin/chruby-exec
-      register: chruby
-    - import_tasks: irregular-apocalypse/chruby.yml
-      vars:
-        version: 0.3.9
-      when: chruby.stat.exists == False
-
-    - stat: path=/usr/local/bin/ruby-install
-      register: ruby_install
-    - import_tasks: irregular-apocalypse/ruby-install.yml
-      vars:
-        version: 0.6.1
-      when: ruby_install.stat.exists == False
-
-    - stat: path=~/.rubies
-      register: rubies
-    - command: ruby-install ruby
-      when: rubies.stat.exists == False
-
-- hosts: all
-  name: install Rust
-  tasks:
-    - stat: path=~/.cargo/bin/rustup
-      register: rustup
-    - import_tasks: irregular-apocalypse/rustup.yml
-      when: rustup.stat.exists == False
-
-    - command: ~/.cargo/bin/rustup toolchain list
-      register: rustup_toolchains
-    - name: install rust
-      command: ~/.cargo/bin/rustup install nightly
-      when: "'nightly' not in rustup_toolchains.stdout"
-
-    - name: default to nightly
-      command: ~/.cargo/bin/rustup default nightly
-
-    - name: install Rust-based tools
-      command: ~/.cargo/bin/cargo install {{ item }}
-      with_items:
-        - exa
-        - ripgrep
-
-- hosts: all
-  name: install fzf
-  tasks:
-    - git:
-        repo: https://github.com/junegunn/fzf.git
-        dest: ~/.fzf
-    - command: ~/.fzf/install
diff --git a/ansible/irregular-apocalypse/.zshrc.local b/ansible/irregular-apocalypse/.zshrc.local
new file mode 100644
index 00000000..0dba029a
--- /dev/null
+++ b/ansible/irregular-apocalypse/.zshrc.local
@@ -0,0 +1 @@
+eval $(ssh-agent -s) > /dev/null
diff --git a/ansible/irregular-apocalypse/js.yml b/ansible/irregular-apocalypse/js.yml
new file mode 100644
index 00000000..ef69883a
--- /dev/null
+++ b/ansible/irregular-apocalypse/js.yml
@@ -0,0 +1,19 @@
+- hosts: all
+  become: yes
+  tasks:
+
+    - name: add the Yarn package repository key
+      apt_key:
+        url: https://dl.yarnpkg.com/debian/pubkey.gpg
+        state: present
+
+    - name: add the Yarn package repository
+      apt_repository:
+        repo: deb https://dl.yarnpkg.com/debian/ stable main
+        state: present
+        filename: yarn
+
+    - name: install Yarn
+      apt:
+        name: yarn
+        update_cache: yes
diff --git a/ansible/irregular-apocalypse/main.yml b/ansible/irregular-apocalypse/main.yml
new file mode 100644
index 00000000..2b931aa2
--- /dev/null
+++ b/ansible/irregular-apocalypse/main.yml
@@ -0,0 +1,108 @@
+---
+- hosts: all
+  pre_tasks:
+    - name: update dotfiles repo
+      git:
+        repo: https://github.com/kejadlen/dotfiles.git
+        dest: ~/.dotfiles
+      ignore_errors: yes
+  tasks:
+    - name: install dependencies
+      apt:
+        name: "{{ item }}"
+        update_cache: yes
+      with_items:
+        - cmake
+        - direnv
+        - make
+        - mosh
+        - libterm-readkey-perl
+        - pkg-config
+        - python3-pip
+        - software-properties-common
+        - zsh
+      become: yes
+
+- hosts: all
+  roles:
+    - dotfiles
+    - zsh
+
+- hosts: all
+  tasks:
+    - name: create home dirs
+      file:
+        path: "{{ item }}"
+        state: directory
+      with_items:
+        - src
+        - tmp
+
+    - name: install Ansible
+      block:
+        - apt_repository:
+            repo: ppa:ansible/ansible
+          become: yes
+        - apt:
+            name: ansible
+            update_cache: yes
+          become: yes
+
+    - name: install Ruby
+      block:
+        - stat: path=/usr/local/bin/chruby-exec
+          register: chruby
+        - import_tasks: chruby.yml
+          vars:
+            version: 0.3.9
+          when: chruby.stat.exists == False
+
+        - stat: path=/usr/local/bin/ruby-install
+          register: ruby_install
+        - import_tasks: irregular-apocalypse/ruby-install.yml
+          vars:
+            version: 0.6.1
+          when: ruby_install.stat.exists == False
+
+        - stat: path=~/.rubies
+          register: rubies
+        - command: ruby-install ruby
+          when: rubies.stat.exists == False
+
+    - name: install Rust
+      block:
+        - stat: path=~/.cargo/bin/rustup
+          register: rustup
+        - import_tasks: irregular-apocalypse/rustup.yml
+          when: rustup.stat.exists == False
+
+        - command: ~/.cargo/bin/rustup toolchain list
+          register: rustup_toolchains
+        - name: install rust
+          command: ~/.cargo/bin/rustup install nightly
+          when: "'nightly' not in rustup_toolchains.stdout"
+
+        - name: default to nightly
+          command: ~/.cargo/bin/rustup default nightly
+
+        # - name: install Rust-based tools
+        #   command: ~/.cargo/bin/cargo install {{ item }}
+        #   with_items:
+        #     - exa
+        #     - ripgrep
+
+    - name: set up JS dev environment
+      import_playbook: js.yml
+
+    - name: install fzf
+      block:
+        - git:
+            repo: https://github.com/junegunn/fzf.git
+            dest: ~/.fzf
+        - command: ~/.fzf/install
+
+    - name: link .zshrc.local
+      file:
+        src: ~/.dotfiles/ansible/irregular-apocalypse/.zshrc.local
+        dest: ~/.zshrc.local
+        state: link